Pages: [1]   Go Down
Author Topic: LED Array - Push button with code, HELP  (Read 915 times)
0 Members and 1 Guest are viewing this topic.
Offline Offline
Newbie
*
Karma: 0
Posts: 1
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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

}
« Last Edit: October 05, 2013, 06:18:56 am by Cont_Zero » Logged

Sydney, Australia
Offline Offline
Edison Member
*
Karma: 33
Posts: 1273
Big things come in large packages
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

If you have already started doing something it will help everyone if you post your code.
Logged

Arduino libraries http://arduinocode.codeplex.com
Parola hardware & library http://parola.codeplex.com

Pages: [1]   Go Up
Jump to: