hello to all,
I'm working on a program to control via RS232 one HDMI switcher.
whole electric circuit is correct. Arduino UNO with ethernet shield and I'm using a MAX232 to convert TTL to RS232. important to note that the TTL code is created by the module SoftwareSerial.
ASCII command for input 1 is "1!\n" and input 2 is "2!\n".
both work perfectly.
But the answer is garbage.
The most interesting is that when I press the physical button switcher the answer comes correct.
to summarize, I just get the garbage when the command is sent by the Arduino UNO.
I need the correct switcher answer to update in the user monitoring interface.
thats my code.
#include <SoftwareSerial.h>
SoftwareSerial Switcher(8, 9); // RX, TX
int PowerButton1Pin = 2;
int PowerButton2Pin = 3;
int VolButtonPlusPin = 5;
int VolButtonMinusPin = 6;
boolean PowerButton1 = false;
boolean PowerButton2 = false;
boolean switchReady = true;
char inChar;
void setup()
{
pinMode(PowerButton1Pin, INPUT);
digitalWrite(PowerButton1Pin,HIGH);
pinMode(PowerButton2Pin, INPUT);
digitalWrite(PowerButton2Pin,HIGH);
// Open serial communications and wait for port to open:
Serial.begin(9600);
// set the data rate for the SoftwareSerial port
Switcher.begin(9600);
}
void loop() // run over and over
{
PowerButton1 = digitalRead(PowerButton1Pin);
PowerButton2 = digitalRead(PowerButton2Pin);
Switcher.listen();
if(Switcher.available())
{
inChar = Switcher.read();
Serial.write(inChar);
}
if(PowerButton1 == true && switchReady == true)
{
Switcher.print("1!\n");
switchReady = false;
}
if(PowerButton2 == true && switchReady == true)
{
Switcher.print("2!\n");
switchReady = false;
}
if(PowerButton1 == false && PowerButton2 == false)
{
switchReady = true;
}
}
please help me