Go Down

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

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
 


Please enter a valid email to subscribe

Confirm your email address

We need to confirm your email address.
To complete the subscription, please click the link in the email we just sent you.

Thank you for subscribing!

Arduino
via Egeo 16
Torino, 10131
Italy