mirror of
https://github.com/supleed2/ELEC50003-P1-CW.git
synced 2024-12-22 21:45:49 +00:00
UART Test program for ESP32 expansion board
Uses ESP32 hardware serial UARTs with pins of Arduino HAT board
This commit is contained in:
parent
98933c77c9
commit
6c31662970
|
@ -1,9 +1,33 @@
|
||||||
#include <Arduino.h>
|
#include <Arduino.h>
|
||||||
#define LED_BUILTIN 2
|
#include <string>
|
||||||
|
|
||||||
|
#define RX1pin 14 // Pin 10 on expansion board
|
||||||
|
#define TX1pin 4 // Pin 11 on expansion board
|
||||||
|
#define RX2pin 15 // Pin 12 on expansion board
|
||||||
|
#define TX2pin 2 // Pin 13 on expansion board
|
||||||
|
|
||||||
|
void forwardprint();
|
||||||
|
|
||||||
|
int counter;
|
||||||
|
String input1, input2;
|
||||||
|
|
||||||
void setup() {
|
void setup() {
|
||||||
Serial.begin(115200);
|
Serial.begin(115200); // Set up hardware UART 0 (Connected to USB port)
|
||||||
|
Serial1.begin(9600, SERIAL_8N1, RX1pin, TX1pin); // Set up hardware UART 1
|
||||||
|
Serial2.begin(9600, SERIAL_8N1, RX2pin, TX2pin); // Set up hardware UART 2
|
||||||
}
|
}
|
||||||
|
|
||||||
void loop() {
|
void loop() {
|
||||||
|
forwardprint();
|
||||||
|
if(Serial.available()){
|
||||||
|
input1 = String(Serial.readStringUntil('\n'));
|
||||||
|
Serial1.println(input1);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void forwardprint() {
|
||||||
|
if(Serial2.available()){
|
||||||
|
input2 = String(Serial2.readStringUntil('\n'));
|
||||||
|
Serial.println(input2);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue