I don't understand how can I make the LEDs and push button act like in the video above.
Can you please explain me how to do this (without using the switch / case statements)?
/////////////////////////////////////////////////////////////////////////////////////////////////
int timer = 50;
int btn = 3; //Step.
int sense = 2; //Dir.
int clock = 0;
int sens = 0;
void setup() {
pinMode(btn, INPUT);
pinMode(sense, INPUT);
for (int x = 8; x< 12; x++){ //led pin 8,9,10,11 OUTPUT
pinMode(x, OUTPUT);
}
}
void loop() {
clock = digitalRead(btn);
sens = digitalRead(sense);
/////// Right / CW /////////////
if (sens == LOW){
if(clock == HIGH){
int x;
x = x+1;
for (int x = 8; x < 12; x++) {
digitalWrite(x, HIGH);
delay(timer);
digitalWrite(x, LOW);
}
}
}
////// Left / CWW //////////////
if (sens == HIGH){
if(clock == HIGH){
int x;
x = x-1;
for (int x = 11; x >= 8;x--) {
digitalWrite(x, HIGH);
delay(timer);
digitalWrite(x, LOW);
}
}
}
}