// *******************************************
// * *
// * NAME : Bode Sekela *
// * Program Name: sketch.ino *
// * Date : 2023-02-21 *
// * Desc : Our second program to make*
// * a tone and play a pattern *
// * *
// *******************************************
int redLED = 12; // pin for my red LED
int greenLED = 11; // pin for my green LED
int yellowLED = 10; // pin for my yellow LED
int buttonPIN = 8; // pin for my button
int patternNumber = 1; // value for pattern number
int delayTime = 100; // delay time for my light patterns
void setup() {
pinMode(redLED, OUTPUT); // config pin 12 to an OUTPUT
pinMode (greenLED, OUTPUT); // config pin 11 to an OUTPUT
pinMode (yellowLED, OUTPUT); // config pin 10 to an OUTPUT
pinMode (buttonPIN, INPUT_PULLUP); // config pin 8 to an INPUT
pinMode (7, OUTPUT); // config pin 7 to an OUTPUT
} // end setup()
void loop() {
if ( digitalRead(buttonPIN) == LOW ){ //check if pressed
patternNumber == patternNumber +1; //check pattern
if (patternNumber = 6){ //check pattern switch
patternNumber == 1; //check pattern switch
}//end if()
tone (7,500,000); //pattern tone
delay(110); //pattern delay
} // end if()
if (patternNumber == 1) {
digitalWrite(redLED, LOW); // send power to pin 12
digitalWrite(greenLED, LOW); // Turn of power to pin 11
digitalWrite(yellowLED, HIGH); // Turn of power to pin 10
delay(delayTime); // wait 3 seconds
digitalWrite(redLED, LOW); // turn off power to pin 12
digitalWrite(greenLED, HIGH); // send power to pin 11
digitalWrite(yellowLED, HIGH); // Turn of power to pin 10
delay(delayTime); // wait 3 seconds
digitalWrite(redLED, HIGH); // turn off power to pin 12
digitalWrite(greenLED, HIGH); // send power to pin 11
digitalWrite(yellowLED, HIGH); // Turn of power to pin 10
delay(delayTime); // wait 3 seconds
}
else if (patternNumber == 2) {
digitalWrite(redLED, HIGH); // send power to pin 12
digitalWrite(greenLED, HIGH); // Turn of power to pin 11
digitalWrite(yellowLED, LOW); // Turn of power to pin 10
delay(delayTime); // wait 3 seconds
digitalWrite(redLED, HIGH); // turn off power to pin 12
digitalWrite(greenLED, LOW); // send power to pin 11
digitalWrite(yellowLED, HIGH); // Turn of power to pin 10
delay(delayTime); // wait 3 seconds
digitalWrite(redLED, LOW); // turn off power to pin 12
digitalWrite(greenLED, HIGH); // send power to pin 11
digitalWrite(yellowLED, HIGH); // Turn of power to pin 10
delay(delayTime); // wait 3 seconds
}
else if (patternNumber == 3) {
digitalWrite(redLED, HIGH); // send power to pin 12
digitalWrite(greenLED, LOW); // Turn of power to pin 11
digitalWrite(yellowLED, LOW); // Turn of power to pin 10
delay(delayTime); // wait 3 seconds
digitalWrite(redLED, LOW); // turn off power to pin 12
digitalWrite(greenLED, HIGH); // send power to pin 11
digitalWrite(yellowLED, LOW); // Turn of power to pin 10
delay(delayTime); // wait 3 seconds
digitalWrite(redLED, LOW); // turn off power to pin 12
digitalWrite(greenLED, LOW); // send power to pin 11
digitalWrite(yellowLED, HIGH); // Turn of power to pin 10
delay(delayTime); // wait 3 seconds
}
else if (patternNumber == 4) {
digitalWrite(redLED, HIGH); // send power to pin 12
digitalWrite(greenLED, LOW); // Turn of power to pin 11
digitalWrite(yellowLED, LOW); // Turn of power to pin 10
delay(delayTime); // wait 3 seconds
digitalWrite(redLED, HIGH); // turn off power to pin 12
digitalWrite(greenLED, HIGH); // send power to pin 11
digitalWrite(yellowLED, LOW); // Turn of power to pin 10
delay(delayTime); // wait 3 seconds
digitalWrite(redLED, HIGH); // turn off power to pin 12
digitalWrite(greenLED, HIGH); // send power to pin 11
digitalWrite(yellowLED, HIGH); // Turn of power to pin 10
delay(delayTime); // wait 3 seconds
}
else if (patternNumber == 5) {
digitalWrite(redLED, LOW); // send power to pin 12
digitalWrite(greenLED, HIGH); // Turn of power to pin 11
digitalWrite(yellowLED, HIGH); // Turn of power to pin 10
delay(delayTime); // wait 3 seconds
digitalWrite(redLED, HIGH); // turn off power to pin 12
digitalWrite(greenLED, LOW); // send power to pin 11
digitalWrite(yellowLED, HIGH); // Turn of power to pin 10
delay(delayTime); // wait 3 seconds
digitalWrite(redLED, HIGH); // turn off power to pin 12
digitalWrite(greenLED, HIGH); // send power to pin 11
digitalWrite(yellowLED, LOW); // Turn of power to pin 10
delay(delayTime); // wait 3 seconds
}
else if (patternNumber == 6) {
digitalWrite(redLED, LOW); // send power to pin 12
digitalWrite(greenLED, LOW); // Turn of power to pin 11
digitalWrite(yellowLED, HIGH); // Turn of power to pin 10
delay(delayTime); // wait 3 seconds
digitalWrite(redLED, LOW); // turn off power to pin 12
digitalWrite(greenLED, HIGH); // send power to pin 11
digitalWrite(yellowLED, LOW); // Turn of power to pin 10
delay(delayTime); // wait 3 seconds
digitalWrite(redLED, HIGH); // turn off power to pin 12
digitalWrite(greenLED, LOW); // send power to pin 11
digitalWrite(yellowLED, LOW); // Turn of power to pin 10
delay(delayTime); // wait 3 seconds
}
}