diff options
Diffstat (limited to 'dev/arduino-terminal/src/main.cpp')
-rw-r--r-- | dev/arduino-terminal/src/main.cpp | 32 |
1 files changed, 32 insertions, 0 deletions
diff --git a/dev/arduino-terminal/src/main.cpp b/dev/arduino-terminal/src/main.cpp new file mode 100644 index 0000000..e1e6813 --- /dev/null +++ b/dev/arduino-terminal/src/main.cpp @@ -0,0 +1,32 @@ +#include "Arduino.h" + +#define BAUD_RATE 115200 + +//called once +void setup() { + Serial.begin(BAUD_RATE); +} + +//called repeatedly +void loop() { + delay(10); +} + +void serialEvent() { + char buffer[64]; + uint8_t idx = 0; + + while (Serial.available()) { + if (idx == 62) { + Serial.println("Input too long"); + return; + } + + char in = (char) Serial.read(); + buffer[idx] = in; + idx += 1; + } + buffer[idx+1] = '\0'; + Serial.print("echo: "); + Serial.write(buffer); +} |