From 480a0df3dd570616158563aac7cf2af8deff15e4 Mon Sep 17 00:00:00 2001 From: mmcwilliams Date: Mon, 11 Apr 2016 17:06:05 -0400 Subject: [PATCH] Arduino test firmware for serial comms Use for timing tests, configuration protocols (figuring out what is attached and which arduino handles which function) --- ino/mcopy_serial_tests/mcopy_serial_tests.ino | 23 +++++++++++++++++++ 1 file changed, 23 insertions(+) create mode 100644 ino/mcopy_serial_tests/mcopy_serial_tests.ino diff --git a/ino/mcopy_serial_tests/mcopy_serial_tests.ino b/ino/mcopy_serial_tests/mcopy_serial_tests.ino new file mode 100644 index 0000000..a1bf89a --- /dev/null +++ b/ino/mcopy_serial_tests/mcopy_serial_tests.ino @@ -0,0 +1,23 @@ +volatile char cmd_char = 'z'; + +void setup() { + Serial.begin(57600); + Serial.flush(); +} + +void loop() { + if (Serial.available()) { + /* read the most recent byte */ + cmd_char = (char)Serial.read(); + } + if (cmd_char != 'z') { + cmd(cmd_char); + cmd_char = 'z'; + } +} + +void cmd (char val) { + if (val == 'a') { + Serial.println("a");//End of action + } +}