Hey, I'm somewhat new to Arduino so bear with me...
I have an LED chaser circuit that utilizes buttons to change specific aspects of it. One button changes the chaser between going from one side to the other to bouncing between the two sides, while the other two change the speed at which the circuit flashes.
The buttons are connected to the 5V output of the board and use that to input into pins, which allows it to detect if they are pressed. The LEDs are each their own circuit.
Currently, both delay buttons work, but not the mode switcher. Can anyone help me on this?
I like to use funny variables in my code, but basically updowns are the status of each button, hammertime is the delay, and shinything is just the LEDs.
int updown1;
int updown2;
int updown3;
int hammertime = 500;
int shinything[] = {2,3,4,5,6};
int x;
int mode;
void setup(){
for (int i=0; i<5; i=i+1){
pinMode(shinything[i], OUTPUT);
}
pinMode(8,INPUT);
pinMode(9,INPUT);
pinMode(10,INPUT);
}
void loop(){
updown1=digitalRead(8);
updown2=digitalRead(9);
updown3=digitalRead(10);
if(updown1 == 1){
if(mode == 1){
mode = 0;
}
else{
mode = 1;
}
}
if(mode == 1){
while(x){
updown1=digitalRead(8);
updown2=digitalRead(9);
updown3=digitalRead(10);
if(updown2 == 1){
hammertime = hammertime+100;
}
if(updown3 == 1){
hammertime = hammertime-100;
}
if(updown1 == 1){
break;
}
for(int i=4; i>-1; i--){
digitalWrite(shinything[i], HIGH);
delay(hammertime);
digitalWrite(shinything[i], LOW);
}
for(int i=0; i<5; i++){
digitalWrite(shinything[i], HIGH);
delay(hammertime);
digitalWrite(shinything[i], LOW);
}
}
}
if(updown2 == 1){
hammertime = hammertime+100;
}
if(updown3 == 1){
hammertime = hammertime-100;
}
for(int i=0; i<5; i++){
digitalWrite(shinything[i], HIGH);
delay(hammertime);
digitalWrite(shinything[i], LOW);
}
}