//Pin layout
int ledRed = 2;
int ledYellow = 3;
int ledGreen = 5;
int Step = 1;
// Switch and Counter Setup
const int Switch = 8;
void setup(){
// Organzize Lights
pinMode(ledRed, OUTPUT);
pinMode(ledYellow, OUTPUT);
pinMode(ledGreen, OUTPUT);
//Establish pinmode for Switch
pinMode(Switch, INPUT_PULLUP); //PULLUP means internal pullup resistor active
//Establish Serial Monitor
Serial.begin(9600);}
void loop(){
//ledCounter Function
for(int ledCounter = 0; ledCounter > -1; ledCounter = ledCounter + Step){
// Function Names for Counter (Necessary for voids #)
if (ledCounter == 0) Zero();
if (ledCounter == 1) One();
if (ledCounter == 2) Two();
if (ledCounter == 3) Three();
if (ledCounter == 4) Four();
if (ledCounter == 5) Five();
if (ledCounter == 6) Six();
if (ledCounter == 7) Seven();
if (ledCounter == 8) Eight();
if (ledCounter == 9) Nine();
if (ledCounter == 10) Ten();
if (ledCounter == 11) Eleven();
//If Statement to Count-Backwards (When counter reaches 12)
if (ledCounter > 11) Step=-12;
delay(1000);
//Prints "Counter #" in Serial Monitor Tab
Serial.print("ledCounter= ");
Serial.println(ledCounter);}
// Count-Forwards (When counter reaches 0)
Step = 1;}
//Green LED Cycle (5 Seconds Phase)
void Zero(){
digitalWrite (ledGreen, HIGH);
digitalWrite (ledYellow, LOW);
digitalWrite (ledRed, LOW);}
void One(){
digitalWrite (ledGreen, HIGH);
digitalWrite (ledYellow, LOW);
digitalWrite (ledRed, LOW);}
void Two(){
digitalWrite (ledGreen, HIGH);
digitalWrite (ledYellow, LOW);
digitalWrite (ledRed, LOW);}
void Three(){
digitalWrite (ledGreen, HIGH);
digitalWrite (ledYellow, LOW);
digitalWrite (ledRed, LOW);}
void Four(){
digitalWrite (ledGreen, HIGH);
digitalWrite (ledYellow, LOW);
digitalWrite (ledRed, LOW);}
//Yellow LED Cycle (2 Second Phase)
void Five(){
digitalWrite (ledYellow, HIGH);
digitalWrite (ledRed, LOW);
digitalWrite (ledGreen, LOW);}
void Six(){
digitalWrite (ledYellow, HIGH);
digitalWrite (ledRed, LOW);
digitalWrite (ledGreen, LOW);}
//Red LED Cycle (5 Seconds Phase)
void Seven(){
digitalWrite (ledRed, HIGH);
digitalWrite (ledGreen, LOW);
digitalWrite (ledYellow, LOW);}
void Eight(){
digitalWrite (ledRed, HIGH);
digitalWrite (ledGreen, LOW);
digitalWrite (ledYellow, LOW);}
void Nine(){
digitalWrite (ledRed, HIGH);
digitalWrite (ledGreen, LOW);
digitalWrite (ledYellow, LOW);}
void Ten(){
digitalWrite (ledRed, HIGH);
digitalWrite (ledGreen, LOW);
digitalWrite (ledYellow, LOW);}
void Eleven(){
digitalWrite (ledRed, HIGH);
digitalWrite (ledGreen, LOW);
digitalWrite (ledYellow, LOW);}
//------------------------------//
//pedCounter Function
int stepVal = 1;
bool buttonState = !digitalRead(Switch);
for loop {(int pedCounter = 100; pedCounter > 99; pedCounter = pedCounter + stepVal; buttonState==HIGH){
// Function Names for pedCounter
if (pedCounter == 100) Onehundred();
if (pedCounter == 101) Onehundredone();
if (pedCounter == 102) Onehundredtwo();
if (pedCounter == 103) Onehundredthree();
if (pedCounter == 104) Onehundredfour();
// //If Statement to Count-Backwards (When counter reaches 104)
if (pedCounter >104) stepVal = -5;
delay (1000);
//Prints "pedCounter #" in Serial Monitor Tab
Serial.print("pedCounter= ");
Serial.println(pedCounter);}
// Count-Forwards (When counter reaches 0)
stepVal = 1;}
//pedLED Cycle (5 Seconds Phase)
void Onehundred(){
digitalWrite (ledRed, HIGH);
digitalWrite (ledGreen, LOW);
digitalWrite (ledYellow, LOW);}
void Onehundredone(){
digitalWrite (ledRed, HIGH);
digitalWrite (ledGreen, LOW);
digitalWrite (ledYellow, LOW);}
void Onehundredtwo(){
digitalWrite (ledRed, HIGH);
digitalWrite (ledGreen, LOW);
digitalWrite (ledYellow, LOW);}
void Onehundredthree(){
digitalWrite (ledRed, HIGH);
digitalWrite (ledGreen, LOW);
digitalWrite (ledYellow, LOW);}
void Onehundredfour(){
digitalWrite (ledRed, HIGH);
digitalWrite (ledGreen, LOW);
digitalWrite (ledYellow, LOW);}