I really cannot get this code to work..
If somebody has the ability and time to correct this and get it running I would be eternally grateful!
I am looking for help writing software for a puffin crossing (Puffin Crossings use traffic lights to stop vehicle traffic, allowing pedestrians to cross . Pedestrians push a button at the side of the road, and wait for a signal to cross - this is from a standing red man to a walking green man. A beeping sound is usually heard when the walking green man is shown)
// Puffin Crossing
#include <LiquidCrystal.h> // include the code:
LiquidCrystal lcd(7, 8, 9, 10, 11, 12); // initiate the code with the numbers on the interface pins
int BUTTON = 2;
int GREEN_LED = 3;
int YELLOW_LED = 4;
int RED_LED = 5;
int d = 2000;
void setup()
// put setup code here for single run:
{
pinMode (2, INPUT);
pinMode (3, OUTPUT);
pinMode (4, OUTPUT);
pinMode (5, OUTPUT);
Serial.begin(9600);
lcd.begin(16, 2); // setup LCD's number of columns and rows:
}
void loop ()
// main code here to run repeatedly:
{
digitalWrite(GREEN_LED, HIGH); // turn the LED on
delay(d); // wait for a second
digitalWrite(GREEN_LED, LOW); // turn the LED off
delay(d); // wait for a second
digitalWrite(YELLOW_LED, HIGH); // turn the LED on
delay(d); // wait for a second
digitalWrite(YELLOW_LED, LOW); // turn the LED off
delay(d); // wait for a second
digitalWrite(RED_LED, HIGH); // turn the LED on
delay(d); // wait for a second
digitalWrite(RED_LED, LOW); // turn the LED off
delay(d); // wait for a second
}
int GREEN_LED = 3;
int YELLOW_LED = 4;
int RED_LED = 5;
int d1 = 2000;
int d2 = 2000;
int d3 = 10000;
void setup()
// setup code here to run once
{
pinMode (2, INPUT);
pinMode (3, OUTPUT);
pinMode (4, OUTPUT);
pinMode (5, OUTPUT);
Serial.begin(9600);
lcd.begin(16, 2); // setup the LCD's number of columns and rows:
}
void loop()
// main code here to run continuously:
{
if (digitalRead(BUTTON) - HIGH)
{
digitalWrite(Green_LED, LOW);
digitalWrite(YELLOW_LED, HIGH);
delay (d2);
digitalWrite(YELLOW_LED, LOW);
digitalWrite(RED_LED, HIGH);
delay (d3);
digitalWrite(YELLOW_LED, HIGH);
delay (d2);
digitalWrite(YELLOW_LED, LOW);
digitalWrite(RED_LED, LOW);
}
else
{
digitalWritet(GREEN_LED, HIGH); //turn the RELAY off by making voltage low
}
}
void setup()
// setup code here to run once:
// pins assigned as follows
{
pinMode (2, INPUT);
pinMode (3, OUTPUT);
pinMode (4, OUTPUT);
pinMode (5, OUTPUT);
Serial.begin(9600); // sets baud rate for serial comms with Serial Monitor
lcd.begin(16, 2); // setup the LCD's number of columns and rows:
}
void loop()
// main code here to run continuously:
//Traffic light control to run light sequence
{
{
lcd.setCursor(2, 0); // set the cursor to column 0. line 1
lcd.print("DO NOT CROSS"); // (note: line 1 is the second row, since counting begins with 0):
}
if (digitalRead(BUTTON) == HIGH) //Read to see if the button is pressed
{
digitalWrite(GREEN_LED, LOW);
digitalWrite(YELLOW_LED, HIGH);
delay (d2);
digitalWrite(YELLOW_LED, LOW);
digitalWrite(RED_LED, HIGH);
lcd.clear();
lcd.setCursor(5, 0);
lcd.print("CROSS");
delay (d3);
lcd.clear();
lcd.setCursor(2, 0);
lcd.print("DO NOT CROSS");
digitalWrite(YELLOW_LED, HIGH);
delay (d2);
digitalWrite(YELLOW_LED, LOW);
digitalWrite(RED_LED, LOW);
lcd.clear();
}
else
{
digitalWrite(GREEN_LED, HIGH); // Turn the Green LED on, a 'normal' state
}