i've been writing the code for my robot (photovore) and this is what it looks like so far.
Servo leftservo; // create servo object to control a servo
int potpin0 = 0; // analog pin used to connect the potentiometer
int left; // variable to read the value from the analog pin
int potpin1 = 1;
leftservo.attach(7); // attaches the servo on pin 9 to the servo object
left = analogRead(potpin0); // reads the value of the potentiometer (value between 0 and 1023)
right = analogRead(potpin1);
left = map(left, 0, 1023, 0, 179);
right = map(right, 0, 1023, 0, 179);
I'm pretty sure the beginning is right, but once i get past the void loop () part I have no idea what to do. So far, it says (or at least i think it does/want it to) that left is the value that is read from potpin0, and right is the value read from potpin1. It then converts it from 0-1023 to the 0-180 that the servo can read. Now, I;m trying to make it say that if left < right, then turn left. If left > right, then turn right. And if left == right, then go straight. How do I do that?
(I already tried downloading the pre written code for the roboduino, but for some reason its not letting me open the file, or at least i cannot find the code. So I'm writing my own.)