Commit d5d02752 authored by Jakub,Kolodziejski's avatar Jakub,Kolodziejski

Update traffic-light-arduino.ino

- Fixed resetArduino function to work on Teensy 3.x
- Concatenated help text to one long string instead of multiple Serial.println calls
- Added build date & time
parent f58455a4
......@@ -2,6 +2,8 @@
// Date: 1/10/2019
// Author: Jakub Kolodziejski
#define BUILD_DATE_TIME __DATE__ " " __TIME__
#define NS_GREEN 12
#define NS_YELLOW 14
#define NS_RED 15
......@@ -31,8 +33,12 @@ unsigned long t_dot;
bool auto_run = true;
unsigned long uptime = 0;
// Function to reset the Arduino
void(* resetArduino) (void) = 0; //declare reset function @ address 0
// Function to reset the Teensy 3.x
#define SCB_AIRCR (*(volatile uint32_t *)0xE000ED0C) // Application Interrupt and Reset Control location
void resetArduino(void) {
Serial.end(); //clears the serial monitor if used
SCB_AIRCR = 0x05FA0004; //write value for restart
};
// the setup routine runs once when you press reset:
void setup() {
......@@ -40,6 +46,9 @@ void setup() {
Serial.begin(115200);
Serial.println(F("\n# Serial started"));
Serial.print(F("# Build Date: "));
Serial.println(BUILD_DATE_TIME);
// initialize the light contols pins as an output.
pinMode(LED_BUILTIN, OUTPUT);
......@@ -118,16 +127,18 @@ void loop() {
}
void help() {
Serial.println(F("# Command List"));
Serial.println(F("# ? - Print this help screen"));
Serial.println(F("# r - Reset the Arduino"));
Serial.println(F("# a - Run lights automatically"));
Serial.println(F("# 1 - State 1: NS red, EW red (safety delay)"));
Serial.println(F("# 2 - State 2: NS green, EW red"));
Serial.println(F("# 3 - State 3: NS yellow, EW red"));
Serial.println(F("# 4 - State 4: NS red, EW red (safety delay)"));
Serial.println(F("# 5 - State 5: NS red, EW green"));
Serial.println(F("# 6 - State 6: NS red, EW yellow"));
Serial.print(F("# Build Date: "));
Serial.println(BUILD_DATE_TIME);
Serial.println(F( "# Command List\n"
"# ? - Print this help screen\n"
"# r - Reset the Arduino\n"
"# a - Run lights automatically\n"
"# 1 - State 1: NS red, EW red (safety delay)\n"
"# 2 - State 2: NS green, EW red\n"
"# 3 - State 3: NS yellow, EW red\n"
"# 4 - State 4: NS red, EW red (safety delay)\n"
"# 5 - State 5: NS red, EW green\n"
"# 6 - State 6: NS red, EW yellow"));
}
void all_off() {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment