Go Down

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

Cont_Zero

Oct 04, 2013, 10:32 pm Last 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)?

http://www.youtube.com/watch?v=KFvzvg6OtF0

/////////////////////////////////////////////////////////////////////////////////////////////////

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

}

marco_c

If you have already started doing something it will help everyone if you post your code.
Arduino libraries http://arduinocode.codeplex.com
Parola for Arduino http://parola.codeplex.com

Go Up