From 7aff146ad7b3bdd70901f77b0aadfc32dbdd56f5 Mon Sep 17 00:00:00 2001 From: Stanley Huang Date: Sat, 5 Dec 2015 15:49:28 +1100 Subject: Update example sketches for OBD library --- libraries/OBD/examples/obd_i2c_test/obd_i2c_test.ino | 20 +++++++++++++------- .../OBD/examples/obd_uart_test/obd_uart_test.ino | 7 +++++-- 2 files changed, 18 insertions(+), 9 deletions(-) (limited to 'libraries/OBD') diff --git a/libraries/OBD/examples/obd_i2c_test/obd_i2c_test.ino b/libraries/OBD/examples/obd_i2c_test/obd_i2c_test.ino index 9911897..fe9141a 100644 --- a/libraries/OBD/examples/obd_i2c_test/obd_i2c_test.ino +++ b/libraries/OBD/examples/obd_i2c_test/obd_i2c_test.ino @@ -55,25 +55,31 @@ void readMEMS() accelgyro.getMotion6(&ax, &ay, &az, &gx, &gy, &gz); temp = accelgyro.getTemperature(); - // display MEMS data + Serial.print('['); + Serial.print(millis()); + Serial.print(']'); + Serial.print("ACC="); Serial.print(ax); - Serial.write('/'); + Serial.print('/'); Serial.print(ay); - Serial.write('/'); - Serial.println(az); + Serial.print('/'); + Serial.print(az); - Serial.print("GYRO="); + Serial.print(" GYRO="); Serial.print(gx); - Serial.write('/'); + Serial.print('/'); Serial.print(gy); - Serial.write('/'); + Serial.print('/'); Serial.println(gz); } void readPID() { static const byte pidlist[] = {PID_ENGINE_LOAD, PID_COOLANT_TEMP, PID_RPM, PID_SPEED, PID_TIMING_ADVANCE, PID_INTAKE_TEMP, PID_THROTTLE, PID_FUEL_LEVEL}; + Serial.print('['); + Serial.print(millis()); + Serial.print(']'); for (byte i = 0; i < sizeof(pidlist) / sizeof(pidlist[0]); i++) { byte pid = pidlist[i]; bool valid = obd.isValidPID(pid); 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 944d6f2..adb68b0 100644 --- a/libraries/OBD/examples/obd_uart_test/obd_uart_test.ino +++ b/libraries/OBD/examples/obd_uart_test/obd_uart_test.ino @@ -13,8 +13,8 @@ // 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); -//#define mySerial Serial +//SoftwareSerial mySerial(A2, A3); +#define mySerial Serial COBD obd; @@ -51,6 +51,9 @@ void testOut() void readPID() { static const byte pidlist[] = {PID_ENGINE_LOAD, PID_COOLANT_TEMP, PID_RPM, PID_SPEED, PID_TIMING_ADVANCE, PID_INTAKE_TEMP, PID_THROTTLE, PID_FUEL_LEVEL}; + mySerial.print('['); + mySerial.print(millis()); + mySerial.print(']'); for (byte i = 0; i < sizeof(pidlist) / sizeof(pidlist[0]); i++) { byte pid = pidlist[i]; bool valid = obd.isValidPID(pid); -- cgit v1.2.3