diff options
author | Stanley Huang <stanleyhuangyc@gmail.com> | 2015-12-05 15:15:46 +1100 |
---|---|---|
committer | Stanley Huang <stanleyhuangyc@gmail.com> | 2015-12-05 15:15:46 +1100 |
commit | c25dc8142813ad90438a42f1c5e5dd8d538ff428 (patch) | |
tree | 7d27435d8251e2091ffb39315201297cfec6118c /libraries/OBD/examples/obd_uart_test | |
parent | b6c5e2146584b98629ca3bffa74882af185b78da (diff) | |
download | 2021-arduino-obd-c25dc8142813ad90438a42f1c5e5dd8d538ff428.tar.gz 2021-arduino-obd-c25dc8142813ad90438a42f1c5e5dd8d538ff428.tar.bz2 2021-arduino-obd-c25dc8142813ad90438a42f1c5e5dd8d538ff428.zip |
Update example sketch
Diffstat (limited to 'libraries/OBD/examples/obd_uart_test')
-rw-r--r-- | libraries/OBD/examples/obd_uart_test/obd_uart_test.ino | 15 |
1 files changed, 11 insertions, 4 deletions
diff --git a/libraries/OBD/examples/obd_uart_test/obd_uart_test.ino b/libraries/OBD/examples/obd_uart_test/obd_uart_test.ino index 5b03e95..944d6f2 100644 --- a/libraries/OBD/examples/obd_uart_test/obd_uart_test.ino +++ b/libraries/OBD/examples/obd_uart_test/obd_uart_test.ino @@ -11,8 +11,9 @@ #include <SoftwareSerial.h> #include <OBD.h> +// On Arduino Leonardo, Micro, MEGA or DUE, hardware serial can be used for output +// as OBD-II adapter should connect to Serial1, otherwise we use software serial SoftwareSerial mySerial(A2, A3); -// On Arduino Leonardo, Micro or MEGA, OBD-II adapter should connect to Serial1, so Serial can be used as output //#define mySerial Serial COBD obd; @@ -66,13 +67,18 @@ void readPID() mySerial.println(); } -void setup() { +void setup() +{ delay(500); mySerial.begin(115200); + // this will begin serial obd.begin(); + // send some commands for testing and show response + testOut(); + + // initialize OBD-II adapter do { - testOut(); mySerial.println("Init..."); } while (!obd.init()); @@ -84,6 +90,7 @@ void setup() { delay(1000); } -void loop() { +void loop() +{ readPID(); } |