int x = 0;
int y= 1;
int xval = 0;
int yval = 0;
void setup() {
// put your setup code here, to run once:
Serial.begin(9600);
pinMode(x, INPUT);
pinMode(y, INPUT);
}
void loop() {
// put your main code here, to run repeatedly:
xval = map(analogRead(x),0,1023, 0, 180);
yval = analogRead(y);
if(yval > 512)
{
Serial.print("FORWARD"); Serial.println("\n");
Serial.print("Speed = "); Serial.println(abs(map(yval,0,1023,255, -255)));Serial.println("\n");
Serial.print("Angle = "); Serial.println(xval);
}
else if(yval < 512)
{
Serial.print("REVERSE"); Serial.println("\n");
Serial.print("Speed = "); Serial.println(abs(map(yval,0,1023,255, -255)));Serial.println("\n");
Serial.print("Angle = "); Serial.println(xval);
}
else
{
Serial.print("STOP"); Serial.println("\n");
}
delay(1000);
}