Go Down

Topic: Not Declared???? (Read 379 times) previous topic - next topic

kidpreacher5325

Thank you all for your help.  After reading the comments, plus going back to the reference pages, I was able to make the following sketch work.

Code: [Select]


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 inpu 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:

if (digitalRead (A0) == HIGH){
digitalWrite(13, HIGH); // toggle switch on countdown mode (high) LED13 is on until push button activates timer.


if (digitalRead (A1) == 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
}
}
if (digitalRead (A0) == LOW){
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);
}
}



kidpreacher5325

Last and final note.  Made final adjustments so that the "demo Mode" loop has 3 lights on at a time doing the chase light thing.  This actually shortened the sketch and made it process faster, as well as looks better.  Here is the  finalized sketch.

Code: [Select]


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 inpu 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:

if (digitalRead (A0) == HIGH){
digitalWrite(13, HIGH); // toggle switch on countdown mode (high) LED13 is on until push button activates timer.
digitalWrite(10, LOW);
digitalWrite(6, LOW);
digitalWrite(2, LOW);

if (digitalRead (A1) == 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
}
}
if (digitalRead (A0) == LOW){
digitalWrite(10, LOW);
digitalWrite(6, LOW);
digitalWrite(2, LOW);
digitalWrite(13, HIGH); //LED quick loop when toggle is in display (low) mode
digitalWrite(9, HIGH);
digitalWrite(5, HIGH);
delay (320);
digitalWrite(13, LOW); //led13 off
digitalWrite(9, LOW);
digitalWrite(5, LOW);
digitalWrite(12, HIGH);
digitalWrite(8, HIGH);//led 12 on
digitalWrite(4, HIGH);
delay (320); //  quarter second delay
digitalWrite(12, LOW);// led 12 off
digitalWrite(8, LOW);
digitalWrite(4, LOW);
digitalWrite(11, HIGH);
digitalWrite(7, HIGH);
digitalWrite(3, HIGH);
delay (320);
digitalWrite(11, LOW);
digitalWrite(7, LOW);
digitalWrite(3, LOW);
digitalWrite(10, HIGH);
digitalWrite(6, HIGH);
digitalWrite(2, HIGH);
delay (100);


}
}




Thanks again for all those who helped.  Be blessed.

AWOL

Code: [Select]
      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

Isn't that the same as 
Code: [Select]
for (byte i = 13; i > 2; i--)
{
  digitalWrite (i, LOW);
  digitalWrite (i - 1, HIGH);
  delay (3000);
}
delay (7000);
digitalWrite (2, LOW)
"Pete, it's a fool looks for logic in the chambers of the human heart." Ulysses Everett McGill.
Do not send technical questions via personal messaging - they will be ignored.

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