hi everyone
My first post here and i'm hoping someone might be able to point me in the right direction.
what i'm trying to achieve (badly if i say so myself)
starting with a value of zero for "a"
to input a number using the serial monitor (this will hopefully later come from a analog input)
then step to that number ...then be able to enter another number and step from the previous to the new number.
I thought i could do this by passing a to b ..but obviously that don't work
i've been banging my head for a while....and can't even work out if this is an easy thing or a hard thing ...don't even know what the procedure would be called so i don't know what to search for
any pointers would be great.....as i'm old and my brain has stopped working
thanks for reading
merry Christmas
here's where i'm at
int a = 100;
int b = 20;
void setup() {
Serial.begin(115200);
}
void loop() {
if (Serial.available()>0){int a = Serial.parseInt();Serial.println(a); // reads from serial monitor
if (a < b){Serial.println("positive up");
do {a++; Serial.println(a); delay (20);} while(a != b); Serial.println("+++"); }
if (a > b){Serial.println("negative down");
do {a--; Serial.println(a); delay (20);} while(b != a); Serial.println("---");}
b = a;
}
}