#include <HardwareSerial.h>
HardwareSerial SerialPort(2); // use UART2
char number = ' ';
int builtInLED = 2; // Assuming the built-in LED is connected to GPIO pin 2
void setup() {
Serial.begin(9600); // Start the serial monitor at a baud rate of 9600
SerialPort.begin(15200, SERIAL_8N1, 16, 17);
pinMode(builtInLED, OUTPUT); // Use the pin number connected to the built-in LED
Serial.println("Serial Monitoring Started");
}
void loop() {
if (SerialPort.available()) {
char receivedChar = SerialPort.read();
if (receivedChar == '0') {
digitalWrite(builtInLED, LOW); // Turn off the built-in LED
Serial.println("Built-in LED turned off");
}
if (receivedChar == '1') {
digitalWrite(builtInLED, HIGH); // Turn on the built-in LED
Serial.println("Built-in LED turned on");
}
}
}