takeup/ino/softserial_mock/softserial_mock.ino

36 lines
621 B
Arduino
Raw Normal View History

#include <SoftwareSerial.h>
/**
* CONSTANTS
**/
#define rSignal 7
#define tSignal 8
const int serialDelay = 5;
SoftwareSerial softSerial (rSignal, tSignal);
volatile char cmdChar = 'z';
void setup() {
Serial.begin(57600);
Serial.flush();
Serial.setTimeout(serialDelay);
softSerial.begin(9600);
softSerial.flush();
softSerial.setTimeout(serialDelay);
}
void loop () {
if (Serial.available()) {
cmdChar = (char)Serial.read();
2023-02-13 20:28:21 +00:00
softSerial.write(cmdChar);
2023-02-13 20:09:26 +00:00
Serial.println(cmdChar);
}
2023-02-13 20:40:56 +00:00
if (softSerial.available()) {
cmdChar = (char)softSerial.read();
Serial.println(cmdChar);
}
}