Go Down

Topic: LED Array - Push button with code, HELP (Read 1 time)previous topic - next topic

Cont_Zero

Oct 04, 2013, 10:32 pmLast Edit: Oct 05, 2013, 01:18 pm by Cont_Zero Reason: 1
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() {

/////// 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);
}
}
}

}

marco_c

#1
Oct 05, 2013, 03:14 am
If you have already started doing something it will help everyone if you post your code.
Arduino Libraries https://github.com/MajicDesigns?tab=Repositories
Parola for Arduino https://github.com/MajicDesigns/Parola
Arduino++ blog https://arduinoplusplus.wordpress.com

Go Up