Created
August 12, 2021 00:15
-
-
Save AlienKevin/9c9fdd61c6d5b3be69424b951e65958b to your computer and use it in GitHub Desktop.
arduino-nano-33-ble-uart/transmitter.cpp
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#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