Skip to content

Instantly share code, notes, and snippets.

@ncwhale
Last active February 28, 2018 13:02
Show Gist options
  • Save ncwhale/8303b51656cf5aca791acb74f5043d97 to your computer and use it in GitHub Desktop.
Save ncwhale/8303b51656cf5aca791acb74f5043d97 to your computer and use it in GitHub Desktop.
bool ledBinkStatus = false;
//SoftwareSerial inSerial(0, 1); // RX, TX
void setup() {
// initialize digital pin LED_BUILTIN as an output.
pinMode(LED_BUILTIN, OUTPUT);
// Keep SDA/D2 OUTPUT to LOW
pinMode(2, OUTPUT);
digitalWrite(2, LOW);
// start serial port (On USB)
Serial.begin(115200);
while (!Serial) {
; // wait for serial port to connect. Needed for native USB port only
}
Serial.println("Goodnight moon!");
Serial1.begin(115200);
Serial1.println("Good morning!");
}
void loop() {
if (Serial1.available()) {
Serial.write(Serial1.read());
bink();
}
if (Serial.available()) {
Serial1.write(Serial.read());
bink();
}
}
void bink() {
ledBinkStatus = !ledBinkStatus;
digitalWrite(LED_BUILTIN, ledBinkStatus); // turn the LED on (HIGH is the voltage level)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment