From c9632ab73ccc196d24f44b62e4bc6e98b144b3f9 Mon Sep 17 00:00:00 2001 From: Ladyada Date: Fri, 30 Aug 2019 02:21:23 -0400 Subject: [PATCH] basic i2c demo --- .../GPS_I2C_EchoTest/GPS_I2C_EchoTest.ino | 35 +++++++++++++++++++ 1 file changed, 35 insertions(+) create mode 100644 examples/GPS_I2C_EchoTest/GPS_I2C_EchoTest.ino diff --git a/examples/GPS_I2C_EchoTest/GPS_I2C_EchoTest.ino b/examples/GPS_I2C_EchoTest/GPS_I2C_EchoTest.ino new file mode 100644 index 0000000..6887ac8 --- /dev/null +++ b/examples/GPS_I2C_EchoTest/GPS_I2C_EchoTest.ino @@ -0,0 +1,35 @@ +// Test code for Adafruit GPS That Support Using I2C +// +// This code shows how to test a passthru between USB and I2C +// +// Pick one up today at the Adafruit electronics shop +// and help support open source hardware & software! -ada + +#include + +// Connect to the GPS on the hardware I2C port +Adafruit_GPS GPS(&Wire); + + +void setup() { + // wait for hardware serial to appear + while (!Serial); + + // make this baud rate fast enough to we aren't waiting on it + Serial.begin(115200); + + Serial.println("Adafruit GPS library basic I2C test!"); + GPS.begin(0x10); // The I2C address to use is 0x10 +} + + +void loop() { + if (Serial.available()) { + char c = Serial.read(); + GPS.write(c); + } + if (GPS.available()) { + char c = GPS.read(); + Serial.write(c); + } +} \ No newline at end of file