Hello.. I am building a light tree count down timer for our church game night. there will be 12 horizontal rows on a square post, each row with 3 or 4 LEDs. The top LEDs (blue) will be a "get ready", the next 10 rows will be the count down, and the final bottom row will be a "TIMES UP" row. I may hook a buzzer to that output too if there is enough current.
On analog A0 I have a toggle switch (with a pull down resistor) and on A1 I have a push button (also with a pull down resistor). When the toggle is in the "LOW" position, my sketch is set to have each row light up every 1/4 second - a display mode. When you switch the toggle to "HIGH", I want it to go to an "IF/Else" mode. The if/else would have the DigitalPin 13 to HIGH and hold until the pushbutton is pushed. That would activate each row of light for 3 seconds each for a total 30 second timer, followed by a 10 second buzzer and lights to say times up. it would then reset itself back to the digital13 until the pushbutton is pushed again, or the toggle is put back in display mode.
I have read all the reference and tutorial items, and thought I had it right, but when I go to upload my sketch, it keeps giving me errors on the inputs and "IF" statements.
If I do "if (input0=HIGH)" I get input 0 not declared. If I do If (input A0=HIGH) it says Assignment of read only... Nothing works. Here is the sketch. If someone can PLEASE show me (and make corrections) I would truly be thankful. Also, how do I get a debounce? I thought of just cutting and pasting, but as I can not get the basic part to work, I did not want to add more... Thanks again.
void setup() {
// put your setup code here, to run once:
pinMode (A0, INPUT); //analog input to toggle switch -resistor to ground on return side
pinMode (A1, INPUT); //analog input to push button - resistor to ground on return side
pinMode (13, OUTPUT); //LED = Get Ready - all LED outputs have 3 parallel LEDs with resistors.
pinMode (12, OUTPUT); // LED countdown light 10
pinMode (11, OUTPUT); // LED countdown light 9
pinMode (10, OUTPUT); // LED countdown light 8
pinMode (9, OUTPUT); // LED countdown light 7
pinMode (8, OUTPUT); // LED countdown light 6
pinMode (7, OUTPUT); // LED countdown light 5
pinMode (6, OUTPUT); // LED countdown light 4
pinMode (5, OUTPUT); // LED countdown light 3
pinMode (4, OUTPUT); // LED countdown light 2
pinMode (3, OUTPUT); // LED countdown light 1
pinMode (2, OUTPUT); // LED countdown TIMES UP plus buzzer
}
void loop() {
// put your main code here, to run repeatedly:
digitalWrite(13, HIGH); //LED quick loop when toggle is in display (low) mode
delay (250);
digitalWrite(13, LOW); //led13 off
digitalWrite(12, HIGH);//led 12 on
delay (250); // quarter second delay
digitalWrite(12, LOW);// led 12 off
digitalWrite(11, HIGH);
delay (250);
digitalWrite(11, LOW);
digitalWrite(10, HIGH);
delay (250);
digitalWrite(10, LOW);
digitalWrite(9, HIGH);
delay (250);
digitalWrite(9, LOW);
digitalWrite(8, HIGH);
delay (250);
digitalWrite(8, LOW);
digitalWrite(7, HIGH);
delay (250);
digitalWrite(7, LOW);
digitalWrite(6, HIGH);
delay (250);
digitalWrite(6, LOW);
digitalWrite(5, HIGH);
delay (250);
digitalWrite(5, LOW);
digitalWrite(4, HIGH);
delay (250);
digitalWrite(4, LOW);
digitalWrite(3, HIGH);
delay (250);
digitalWrite(3, LOW);
digitalWrite(2, HIGH);
delay (250);
digitalWrite(2, LOW);
delay (250);
int analogPin (0);
if (input0=HIGH)
digitalWrite(13, HIGH); // toggle switch on countdown mode (high) LED13 is on until push button activates timer.
if (input1=HIGH)
digitalWrite(13, LOW); //push button activates countdown timer, turning off 13 and working down timer LEDs at 3 seconds each for 30 second game time.
digitalWrite(12, HIGH);
delay (3000);
digitalWrite(12, LOW);
digitalWrite(11, HIGH);
delay (3000);
digitalWrite(11, LOW);
digitalWrite(10, HIGH);
delay (3000);
digitalWrite(10, LOW);
digitalWrite(9, HIGH);
delay (3000);
digitalWrite(9, LOW);
digitalWrite(8, HIGH);
delay (3000);
digitalWrite(8, LOW);
digitalWrite(7, HIGH);
delay (3000);
digitalWrite(7, LOW);
digitalWrite(6, HIGH);
delay (3000);
digitalWrite(6, LOW);
digitalWrite(5, HIGH);
delay (3000);
digitalWrite(5, LOW);
digitalWrite(4, HIGH);
delay (3000);
digitalWrite(4, LOW);
digitalWrite(3, HIGH);
delay (3000);
digitalWrite(3, LOW);
digitalWrite(2, HIGH); //hold for 10 seconds, playing buzzer and light for TIMES UP, then reset to 13
delay (10000);
digitalWrite(2, LOW); //light and buzzer off
}