So I'm kinda new to bynk and I need some help
I am trying to use an Arduino with an ethernet shield to program a traffic light to my high school bell schedule and I am having issues with the code.
I have programmed it so that when the light is green we have work time when it is yellow ten minutes left in class and red during class changes and that an easy code but I am trying to link the clock widget on blynk to it so it can start and stop at a specific time every day.
#include <SPI.h>
#include <Ethernet.h>
#include <BlynkSimpleEthernet.h>
#include <TimeLib.h>
#include <WidgetRTC.h>
int GREEN = 6;
int YELLOW = 7;
int RED = 8;
int DELAYGREENQRT = 1200000;
int DELAYYELLOWQRT = 300000;
int DELAYREDQRT = 360000;
int DELAYGREEN1stPD = 4140000;
int DELAYYELLOW1stPD = 900000;
int DELAYRED1stPD = 360000;
int DELAYGREEN2ndPD = 4140000;
int DELAYYELLOW2ndPD = 900000;
int DELAYRED2ndPD = 360000;
int DELAYREDLUNCH = 1710000;
int DELAYGREEN3rdPD = 4230000;
int DELAYYELLOW3rdPD = 900000;
int DELAYRED3rdPD = 360000;
int DELAYGREEN4thPD = 4140000;
int DELAYYELLOW4thPD = 900000;
int DELAYRED4thPD = 360000;
char auth[] = “YourAuthToken”;
BlynkTimer timer;
WidgetRTC rtc;
// Digital clock display of the time
void clockDisplay()
{
// You can call hour(), minute(), … at any time
// Please see Time library examples for details
String currentTime = String(hour()) + “:” + minute() + “:” + second();
String currentDate = String(day()) + “ ” + month() + “ ” + year();
Serial.print(“Current time: ”);
Serial.print(currentTime);
Serial.print(“ ”);
Serial.print(currentDate);
Serial.println();
// Send time to the App
Blynk.virtualWrite(V1, currentTime);
// Send date to the App
Blynk.virtualWrite(V2, currentDate);
}
BLYNKCONNECTED() {
// Synchronize time on connection
rtc.begin();
}
void setup()
{
Blynk.begin(auth);
// Other Time library functions can be used, like:
// timeStatus(), setSyncInterval(interval)…
// Read more: Time Library, Timekeeping and Time/Date Manipulation on Teensy
pinMode(GREEN, OUTPUT);
pinMode(YELLOW, OUTPUT);
pinMode(RED, OUTPUT);
}
void loop()
{
pinMode(GREEN, OUTPUT);
pinMode(YELLOW, OUTPUT);
pinMode(RED, OUTPUT);
}
void loop()
{
greenlight();
delay(DELAYGREENQRT);
yellowlight();
delay(DELAYYELLOWQRT);
redlight();
delay(DELAYREDQRT);
greenlight();
delay(DELAYGREEN1stPD);
yellowlight();
delay(DELAYYELLOW1stPD);
redlight();
delay(DELAYRED1stPD);
greenlight();
delay(DELAYGREEN2ndPD);
yellowlight();
delay(DELAYYELLOW2ndPD);
redlight();
delay(DELAYRED2ndPD);
redlight();
delay(DELAYREDLUNCH);
greenlight();
delay(DELAYGREEN3rdPD);
yellowlight();
delay(DELAYYELLOW3rdPD);
redlight();
delay(DELAYRED3rdPD);
greenlight();
delay(DELAYGREEN4thPD);
yellowlight();
delay(DELAYYELLOW4thPD);
redlight();
delay(DELAYRED4thPD);
}
void greenlight()
{
digitalWrite(GREEN, HIGH);
digitalWrite(YELLOW, LOW);
digitalWrite(RED, LOW);
}
void yellowlight()
{
digitalWrite(GREEN, LOW);
digitalWrite(YELLOW, HIGH);
digitalWrite(RED, LOW);
}
void redlight()
{
digitalWrite(GREEN, LOW);
digitalWrite(YELLOW, LOW);
digitalWrite(RED, HIGH);
}