Don't ad-block us - support your favorite websites. We have safe, unobstrusive, robotics related ads that you actually want to see - see here for more.
0 Members and 1 Guest are viewing this topic.
//This will be the input pin for the pot, I will set it here but possibly changeint potPin = 0;int val = 0;void setup(){ Serial.begin(9600);}void loop(){ val = analogRead(potPin); //read value from the pot val = map(val, 0 1023, 0, 20); Serial.println(val); //delay(15);}
//read in value from first arduino of slide pot//#include "RoboClaw.h"//#include "BMSerial.h"int potIn = 30;void setup(){ Serial.begin(9600);}void loop(){ //stays until receive value front arduino1 while(Serial.available() == 0); //range from 0 to 30 //converting char value into integer int data = Serial.read() - '0'; //pot range of 180 deg, change since we want be using the full 180? int pos = map(data,0,30,0,180); pos = constrain(pos,0,180); //val = analogRead(potPin); Serial.flush();}
http://www.inpharmix.com/jps/PID_Controller_For_Lego_Mindstorms_Robots.htmlthis made me understand how PID works, this guy is great.
val = map(val, 0 1023, 0, 20);
val = map(val, 0, 1023, 0, 20);