#define fwdRev_JS A0
#define rotateLR_JS A1
#define upDown_JS A2
#define tiltLR_JS A3
int fwdVal, revVal, rotLeftVal, rotRightVal, upVal, downVal, titlLeftVal, tiltRightVal;
void setup() {
// put your setup code here, to run once:
Serial.begin(115200);
}
void loop() {
// put your main code here, to run repeatedly:
readSensors();
Serial.print("rawValue :");
Serial.println(analogRead(A0));
Serial.print("fwdVal :");
Serial.print(fwdVal);
Serial.print(" revVal :");
Serial.println(revVal);
delay(500);
}
void readSensors() {
fwdVal = map(analogRead(A0), 502, 0, 0, 255);
if (fwdVal > 255) {
fwdVal = 255;
}
else if (fwdVal < 0) {
fwdVal = 0;
}
revVal = map(analogRead(A0), 522, 1023, 0, 255);
if (revVal > 255) {
revVal = 255;
}
else if (revVal < 0) {
revVal = 0;
}
}