What's wrong with the following program? I can see the output of A3 (Tx) in the picocom terminal, but when I type something, it is not seen as input in mySerial Rx.
#include <LiquidCrystal.h>
#include <SoftwareSerial.h>
int c='A';
// initialize the library by associating any needed LCD interface pin
// with the arduino pin number it is connected to
const int rs = 12, en = 11, d4 = 5, d5 = 4, d6 = 3, d7 = 2;
LiquidCrystal lcd(rs, en, d4, d5, d6, d7);
SoftwareSerial mySerial = SoftwareSerial(A2, A3);
SoftwareSerial midiSerial = SoftwareSerial(A0, A1); // RX, TX
void setup() {
pinMode(LED_BUILTIN, OUTPUT);
digitalWrite(LED_BUILTIN, LOW);
mySerial.begin(9600);
midiSerial.begin(31250);
// set up the LCD's number of columns and rows:
lcd.begin(16, 2);
// Print a message to the LCD.
lcd.print("MIDI-Channel 1");
}
void loop() {
// set the cursor to column 0, line 1
// (note: line 1 is the second row, since counting begins with 0):
char str[4];
lcd.setCursor(0, 1);
// print the number of seconds since reset:
//lcd.print(millis() / 1000);
delay(1000);
if(mySerial.available() > 0)
c=mySerial.read();
sprintf(str,"%c",c);
lcd.print(str);
midiSerial.write(c);
mySerial.write(c);
}
You are trying to sue 2 instances of SoftwareSerial and I have never seen anyone get this working except under perfect conditions and never with real data
There is a SoftwareSerial listen()) function to set which instance is currently being used but you have not used it in your sketch
Using two SoftwareSerial in the code is definitely not a beginner's level.
Why do you not use hardware Serial for one of input? As I see it not in the code
I modified the code and this way it seems to work:
void loop() {
// set the cursor to column 0, line 1
// (note: line 1 is the second row, since counting begins with 0):
char str[4];
lcd.setCursor(0, 1);
// print the number of seconds since reset:
//lcd.print(millis() / 1000);
delay(1000);
mySerial.listen();
if(mySerial.isListening())
if(mySerial.available() > 0)
c=mySerial.read();
sprintf(str,"%c",c);
lcd.print(str);
midiSerial.write(c);
mySerial.write(c);
}
@b707 : "Why do you not use hardware Serial for one of input? As I see it not in the code"
Because I was recommended (here in this forum) to not tinker with the hardware uart (it seems to interfere with the programming interface).