thanks for your advice, working on it.
it seems i learn the most of video tutorials have seen about 25 now.
but not mush to find about working with, or create your own functions.
put the code into a function and call the function whenever it is needed.
so if anyone now a good tutorial please inform me ![]()
found the glitch !!!! (so happy)
while (Speed <= maxSpeed){
analogWrite(3, Speed); //Sets the speed of the train (255 is ful speed)
Speed = Speed + 1;
delay(40);
}
state = String("goLeft"); //Sets "state"
}
Speed <= maxSpeed sets the speed to 151 not 150 so in the next loop (decrease speed)
it gets to -1 not 0. i guess like an int flips over to negative at 32,767.
-1 on pin 3 gives a positive 255.