Make debug output switchable.

This commit is contained in:
Marcus Scholz 2024-01-11 14:54:49 +01:00
parent 3066ac73cd
commit 88301c8a67

View File

@ -1,6 +1,14 @@
#include <avr/interrupt.h>
#include <avr/sleep.h>
#define DEBUG 1
#if DEBUG == 1
#define Debugln(x) Serial.println(x)
#else
#define Debugln(x)
#endif
// Define relais pins
#define relaisPin_1 12
#define relaisPin_2 13
@ -11,16 +19,16 @@ void setup() {
pinMode(relaisPin_1, OUTPUT);
pinMode(relaisPin_2, OUTPUT);
Serial.println("Hello!");
Debugln("Hello!");
}
void loop() {
delay(2000); // Wait for 2 seconds
Serial.println("Enable power rail #1");
Debugln("Enable power rail #1");
digitalWrite(relaisPin_1, HIGH); // Poweron relais #1
delay(2000);
Serial.println("Enable power rail #2");
Debugln("Enable power rail #2");
digitalWrite(relaisPin_2, HIGH); // Poweron relais #2
delay(50); // wait for UART to finish
@ -29,7 +37,7 @@ void loop() {
void stop() {
// Turn microcontroller off
Serial.println("All done, powering off. Goodbye.");
Debugln("All done, powering off. Goodbye.");
delay(100); // wait for UART to finish
set_sleep_mode(SLEEP_MODE_PWR_DOWN);