You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
52 lines
1.7 KiB
52 lines
1.7 KiB
//#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
|
|
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
|
|
|
|
}
|
|
|
|
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
|
|
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 = Serial1.read();
|
|
// Serial1.println(result);
|
|
Serial1.println("OK");
|
|
// Serial1.println(counter++);
|
|
}
|
|
#endif
|
|
|
|
delay(100);
|
|
}
|