From 5c4300402d931b2cb53db7214877d9b7e69a8416 Mon Sep 17 00:00:00 2001 From: Stanley Huang Date: Fri, 29 Nov 2013 23:13:36 +1100 Subject: update OBD-II library --- libraries/OBD/examples/rpm_led/rpm_led.ino | 36 ---------------------- libraries/OBD/examples/rpm_led_i2c/rpm_led_i2c.ino | 31 +++++++++++++++++++ .../OBD/examples/rpm_led_uart/rpm_led_uart.ino | 30 ++++++++++++++++++ 3 files changed, 61 insertions(+), 36 deletions(-) delete mode 100644 libraries/OBD/examples/rpm_led/rpm_led.ino create mode 100644 libraries/OBD/examples/rpm_led_i2c/rpm_led_i2c.ino create mode 100644 libraries/OBD/examples/rpm_led_uart/rpm_led_uart.ino (limited to 'libraries/OBD/examples') diff --git a/libraries/OBD/examples/rpm_led/rpm_led.ino b/libraries/OBD/examples/rpm_led/rpm_led.ino deleted file mode 100644 index 630336c..0000000 --- a/libraries/OBD/examples/rpm_led/rpm_led.ino +++ /dev/null @@ -1,36 +0,0 @@ -/************************************************************************* -* Sample sketch based on OBD-II library for Arduino -* Distributed under GPL v2.0 -* Copyright (c) 2012-2013 Stanley Huang -* All rights reserved. -*************************************************************************/ - -#include -#include -#include - -// OBD-II UART Adapter -COBD obd; - -// OBD-II I2C Adapter -//COBDI2C obd; - -void setup() -{ - // we'll use the debug LED as output - pinMode(13, OUTPUT); - // start communication with OBD-II UART adapter - obd.begin(); - // initiate OBD-II connection until success - while (!obd.init()); -} - -void loop() -{ - int value; - if (obd.readSensor(PID_RPM, value)) { - // RPM is read and stored in 'value' - // light on LED when RPM exceeds 5000 - digitalWrite(13, value > 5000 ? HIGH : LOW); - } -} diff --git a/libraries/OBD/examples/rpm_led_i2c/rpm_led_i2c.ino b/libraries/OBD/examples/rpm_led_i2c/rpm_led_i2c.ino new file mode 100644 index 0000000..c80eba9 --- /dev/null +++ b/libraries/OBD/examples/rpm_led_i2c/rpm_led_i2c.ino @@ -0,0 +1,31 @@ +/************************************************************************* +* Sample sketch based on OBD-II library for Arduino +* Distributed under GPL v2.0 +* Copyright (c) 2012-2013 Stanley Huang +* All rights reserved. +*************************************************************************/ + +#include +#include + +COBDI2C obd; + +void setup() +{ + // we'll use the debug LED as output + pinMode(13, OUTPUT); + // start communication with OBD-II UART adapter + obd.begin(); + // initiate OBD-II connection until success + while (!obd.init()); +} + +void loop() +{ + int value; + if (obd.read(PID_RPM, value)) { + // RPM is successfully read and its value stored in variable 'value' + // light on LED when RPM exceeds 3000 + digitalWrite(13, value > 3000 ? HIGH : LOW); + } +} diff --git a/libraries/OBD/examples/rpm_led_uart/rpm_led_uart.ino b/libraries/OBD/examples/rpm_led_uart/rpm_led_uart.ino new file mode 100644 index 0000000..8a2ae42 --- /dev/null +++ b/libraries/OBD/examples/rpm_led_uart/rpm_led_uart.ino @@ -0,0 +1,30 @@ +/************************************************************************* +* Sample sketch based on OBD-II library for Arduino +* Distributed under GPL v2.0 +* Copyright (c) 2012-2013 Stanley Huang +* All rights reserved. +*************************************************************************/ + +#include + +COBD obd; + +void setup() +{ + // we'll use the debug LED as output + pinMode(13, OUTPUT); + // start communication with OBD-II UART adapter + obd.begin(); + // initiate OBD-II connection until success + while (!obd.init()); +} + +void loop() +{ + int value; + if (obd.read(PID_RPM, value)) { + // RPM is successfully read and its value stored in variable 'value' + // light on LED when RPM exceeds 3000 + digitalWrite(13, value > 3000 ? HIGH : LOW); + } +} -- cgit v1.2.3