mcopy/notes/esp32_serial/esp32_serial.ino

27 lines
396 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>
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(cmd);
2023-07-04 02:44:43 +00:00
}
cmd = 'z';
2023-07-04 02:44:43 +00:00
}