From c25dc8142813ad90438a42f1c5e5dd8d538ff428 Mon Sep 17 00:00:00 2001 From: Stanley Huang Date: Sat, 5 Dec 2015 15:15:46 +1100 Subject: Update example sketch --- libraries/OBD/examples/obd_uart_test/obd_uart_test.ino | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) (limited to 'libraries/OBD/examples/obd_uart_test') 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 #include +// 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(); } -- cgit v1.2.3