Skip to content

Instantly share code, notes, and snippets.

@AlienKevin
Created August 12, 2021 00:15
Show Gist options
  • Save AlienKevin/9c9fdd61c6d5b3be69424b951e65958b to your computer and use it in GitHub Desktop.
Save AlienKevin/9c9fdd61c6d5b3be69424b951e65958b to your computer and use it in GitHub Desktop.
arduino-nano-33-ble-uart/transmitter.cpp
#include <Arduino.h>
void setup()
{
pinMode(LED_BUILTIN, OUTPUT); // set LED pin as output
digitalWrite(LED_BUILTIN, LOW); // switch off LED pin
Serial.begin(9600); // initialize serial communication at 9600 bits per second:
Serial1.begin(9600); // initialize UART with baud rate of 96007
}
void loop()
{
char c = Serial.read();
if (c == '1')
{
Serial1.println('1');
digitalWrite(LED_BUILTIN, HIGH);
Serial.println("LEDS ON");
}
else if (c == '0')
{
Serial1.println('0');
digitalWrite(LED_BUILTIN, LOW);
Serial.println("LEDS OFF");
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment