From fc944ff979dbbd49a57722fe2d1d2acf47312eb4 Mon Sep 17 00:00:00 2001 From: Jesse Morgan Date: Thu, 20 Oct 2011 22:16:19 -0700 Subject: Inital commit... halfway through the project --- .../NewSoftSerialTest/NewSoftSerialTest.pde | 25 ++++++++++++++++ .../Examples/TwoNSSTest/TwoNSSTest.pde | 33 ++++++++++++++++++++++ 2 files changed, 58 insertions(+) create mode 100644 libraries/NewSoftSerial/Examples/NewSoftSerialTest/NewSoftSerialTest.pde create mode 100644 libraries/NewSoftSerial/Examples/TwoNSSTest/TwoNSSTest.pde (limited to 'libraries/NewSoftSerial/Examples') diff --git a/libraries/NewSoftSerial/Examples/NewSoftSerialTest/NewSoftSerialTest.pde b/libraries/NewSoftSerial/Examples/NewSoftSerialTest/NewSoftSerialTest.pde new file mode 100644 index 0000000..0d9e815 --- /dev/null +++ b/libraries/NewSoftSerial/Examples/NewSoftSerialTest/NewSoftSerialTest.pde @@ -0,0 +1,25 @@ + +#include + +NewSoftSerial mySerial(2, 3); + +void setup() +{ + Serial.begin(57600); + Serial.println("Goodnight moon!"); + + // set the data rate for the NewSoftSerial port + mySerial.begin(4800); + mySerial.println("Hello, world?"); +} + +void loop() // run over and over again +{ + + if (mySerial.available()) { + Serial.print((char)mySerial.read()); + } + if (Serial.available()) { + mySerial.print((char)Serial.read()); + } +} diff --git a/libraries/NewSoftSerial/Examples/TwoNSSTest/TwoNSSTest.pde b/libraries/NewSoftSerial/Examples/TwoNSSTest/TwoNSSTest.pde new file mode 100644 index 0000000..73aa991 --- /dev/null +++ b/libraries/NewSoftSerial/Examples/TwoNSSTest/TwoNSSTest.pde @@ -0,0 +1,33 @@ +#include + +NewSoftSerial nss(2, 3); +NewSoftSerial nss2(4, 5); + +void setup() +{ + nss2.begin(4800); + nss.begin(4800); + Serial.begin(115200); +} + +void loop() +{ + // Every 10 seconds switch from + // one serial GPS device to the other + if ((millis() / 10000) % 2 == 0) + { + if (nss.available()) + { + Serial.print(nss.read(), BYTE); + } + } + + else + { + if (nss2.available()) + { + Serial.print(nss2.read(), BYTE); + } + } +} + -- cgit v1.2.3