From d3e67d28e6010c609d678d8b3f9635db577079f5 Mon Sep 17 00:00:00 2001 From: alanbjohnston Date: Sun, 23 Aug 2020 12:54:22 -0400 Subject: [PATCH] added TESTING flag so can test over Serial Monitor --- arduino/PayloadOK_Pro_Micro.ino | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/arduino/PayloadOK_Pro_Micro.ino b/arduino/PayloadOK_Pro_Micro.ino index 9af67fdf..345add8b 100644 --- a/arduino/PayloadOK_Pro_Micro.ino +++ b/arduino/PayloadOK_Pro_Micro.ino @@ -1,7 +1,14 @@ +//#define TESTING // Uncomment to test code on Serial Monitor + int counter = 0; int RXLED = 17; // The RX LED has a defined Arduino pin void setup() { + +#ifdef TESTING + Serial.begin(9600); +#endif + Serial1.begin(9600); digitalWrite(RXLED, LOW); // set the RX LED ON @@ -14,7 +21,20 @@ void setup() { void loop() { +#ifdef TESTING // ? is sent over Serial Monitor for testing if (Serial.available() > 0) { + digitalWrite(RXLED, LOW); // set the RX LED ON + TXLED0; //TX LED is not tied to a normally controlled pin so a macro is needed, turn LED OFF + delay(50); // wait for a second + digitalWrite(RXLED, HIGH); // set the RX LED ON + TXLED0; //TX LED is not tied to a normally controlled pin so a macro is needed, turn LED OFF + char result = Serial.read(); + // Serial1.println(result); + Serial.println("OK"); + // Serial1.println(counter++); + } +#else // ? is sent by Pi UART + if (Serial1.available() > 0) { digitalWrite(RXLED, LOW); // set the RX LED ON TXLED0; //TX LED is not tied to a normally controlled pin so a macro is needed, turn LED OFF delay(50); // wait for a second @@ -25,6 +45,7 @@ void loop() { Serial1.println("OK"); // Serial1.println(counter++); } +#endif delay(100); }