mcopy/notes/esp32_serial/esp32_serial.ino

29 lines
410 B
Arduino
Raw Normal View History

2023-07-04 02:44:43 +00:00
#include <Arduino.h>
#define RXD2 16
2023-07-04 21:15:26 +00:00
#define TXD2 17
#define LOG_LOCAL_LEVEL ESP_LOG_INFO
#include "esp_log.h"
#include <esp32-hal-log.h>
2023-07-04 02:44:43 +00:00
HardwareSerial Serial2(1);
2023-07-04 21:15:26 +00:00
volatile char cmd = 'z';
2023-07-04 02:44:43 +00:00
void setup () {
2023-07-04 21:15:26 +00:00
Serial2.begin(9600, SERIAL_8N1, RXD2, TXD2);
2023-07-04 02:44:43 +00:00
}
void loop () {
if (Serial2.available() > 0) {
2023-07-04 21:15:26 +00:00
cmd = Serial2.read();
}
if (cmd == 'x') {
Serial2.print('x');
2023-07-04 02:44:43 +00:00
}
}