Hi Everyone,
This is more a question of curiosity than anything.
I have a simple timer program which runs fine. It activates different relays at different times during the program.
The program is working fine.
I have used the Serial.println(); command throughout the program just so I can see where it is up to.
The last few Serial.println() lines displayed show gibberish. Just random charactors and I am wondering why.
The countdown is triggered by a button press and every time the button is pressed it starts fine and display the my messages in the serial monitor but always the last few lines show gibberish.
Can anyone see why? Is it something I have done?
It doesn't seem to effect the program at all, just what is displayed in the serial monitor.
Serial Monitor Read Out
Uneek LEDs 30min Arena Light Timer with 5min warning.
Uses lights 2.4gHz Remote system
Button pressed!
Lights On Signal
Button Press Complete... Entering 30min Timer
Timer at 10min
Timer at 20min
Timer at 25min.. 5m Indicator Light On
Timer at 30min
End of Timer
Turn all Relays off and wait for next keypress
Lights Off Signal
End oæ�Q¥µ•É5)"Õɹ�…±±�I•±…åÍ�½™™�…¹‘�Ý…¥Ñ�™½É�¹•áÑ�•åÁÉ•ÍÍ5)þButton pressed!
Lights On Signal
Button Press Complete... Entering 30min Timer
Timer at 10min
Timer at 20min
Timer at 25min.. 5m Indicator Light On
Timer at 30min
End of Timer
Turn all Relays off and wait for next keypress
Lights Off Signal
End o
#include <LowPower.h>
#define SERIAL_BAUD 115200
#define LED 9 // Moteinos have LEDs on D9
#define BUTTON_INT 1 //user button on interrupt 1 (D3)
#define BUTTON_PIN 3 //user button on interrupt 1 (D3)
#define LightsOn 8 //Turn Lights ON
#define LightsOff 6 //Output Pin for Lights Off
#define Strobelight 7 //Relay Output to activate Strobe light to indicate 5 min left
//RFM69 radio;
void setup() {
Serial.begin(SERIAL_BAUD);
pinMode(BUTTON_PIN, INPUT_PULLUP);
pinMode(LED, OUTPUT);
attachInterrupt(BUTTON_INT, handleButton, FALLING);
pinMode(LightsOn, OUTPUT);
pinMode(LightsOff, OUTPUT);
pinMode(Strobelight, OUTPUT);
// initialize digital pin 4 as an Output to drive the relay to control Turn the Flood Lights on/off
digitalWrite(LightsOff, LOW);
digitalWrite(LightsOff, HIGH);
delay(500); //Simulate Keypress
digitalWrite(LightsOff, LOW);
delay(2000);
digitalWrite(Strobelight, LOW);
digitalWrite(LightsOn, LOW);
Serial.println("Uneek LEDs 30min Arena Light Timer with 5min warning.");
Serial.println("Uses lights 2.4gHz Remote system");
digitalWrite(LightsOff, HIGH);
delay(500); //Simulate Keypress
digitalWrite(LightsOff, LOW);
}
//******** THIS IS INTERRUPT BASED DEBOUNCING FOR BUTTON ATTACHED TO D3 (INTERRUPT 1)
#define FLAG_INTERRUPT 0x01
volatile int mainEventFlags = 0;
boolean buttonPressed = false;
void handleButton()
{
mainEventFlags |= FLAG_INTERRUPT;
}
byte LEDSTATE = LOW; //LOW=0
void loop() {
//******** THIS IS INTERRUPT BASED DEBOUNCING FOR BUTTON ATTACHED TO D3 (INTERRUPT 1)
if (mainEventFlags & FLAG_INTERRUPT)
{
LowPower.powerDown(SLEEP_120MS, ADC_OFF, BOD_ON);
mainEventFlags &= ~FLAG_INTERRUPT;
if (!digitalRead(BUTTON_PIN)) {
buttonPressed = true;
}
}
if (buttonPressed)
{
delay(1000); //button debounce
Serial.println("Button pressed!");
buttonPressed = false;
if (LEDSTATE == LOW)
{
LEDSTATE = HIGH;
digitalWrite(LED, LEDSTATE);
digitalWrite(LightsOff, LOW);
digitalWrite(Strobelight, LOW);
digitalWrite(LightsOn, HIGH);
Serial.println("Lights On Signal");
delay(500); // Wait 0.5 Sec and then Turn off Relay. Simulates a button press
digitalWrite(LightsOn, LOW);
//digitalWrite(LED, LOW);
Serial.println("Button Press Complete... Entering 30min Timer");
//Start 30min Timer
// delay(10L * 60L * 1000L); //Timer at 10min
delay(100000);
Serial.println("Timer at 10min");
// delay(10L * 60L * 1000L); //Timer at 20min
delay(100000);
Serial.println("Timer at 20min");
// delay(300L * 1000L); //Timer at 25min
delay(100000);
digitalWrite(Strobelight, HIGH); // Turn 5min Warning Light on to warn riders the lights will turn off in 5 minutes
Serial.println("Timer at 25min.. 5m Indicator Light On");
// delay(300L * 1000L); //5min delay
delay(100000);
Serial.println("Timer at 30min");
Serial.println("End of Timer");
Serial.println("Turn all Relays off and wait for next keypress");
digitalWrite(LightsOff, HIGH);
Serial.println("Lights Off Signal");
delay(500); //Simulate Keypress
digitalWrite(LightsOff, LOW);
digitalWrite(Strobelight, LOW);
digitalWrite(LED, LOW);
// Serial.println("Timer at 30min");
Serial.println("End of Timer");
Serial.println("Turn all Relays off and wait for next keypress");
LEDSTATE = LOW;
}
}
}