Sending rs232 commands to a display

Hello everyone! I am very new to this Arduino stuff. (I just purchased this little blue board 2 days ago!).

well needless to say my first project was more of a headache then I expected.

Basically I want my Arduino to turn on and off a display when pins X and X get a voltage. I'm taking the code in steps and just want to program the Arduino to turn off the display first. Basically Send X code, wait 10 seconds, send X code, wait 10 seconds... and so on.

Well, I have have the HEX values the manufacture requires, but when I program it in, it does nothing!

My board setup is Arduino Nano (pins 10,11) --> max232 --> rs232 Display.

If I send the hex code to 'myself' the serial monitor sees " ðUÿ@¿". If I hook up the serial monitor directly to the TV and type in " ðUÿ@¿" and press send, the tv gets controlled successfully.

Ive done a loopback test on my rs232/max232 board and I successfully get back what I send.

This is my code, with all the various things ive tried. Ive also tried to do a serial.println(" ðUÿ@¿");

Any guidance is greatly appreciated! Think my max232 board could still be an issue even though it loopbacks correctly?

 // the hex I need is   0xA0 0xF0 0x55 0xFF 0x40 0xBF
#include <SoftwareSerial.h>
SoftwareSerial mySerial(10, 11); //rx tx



void setup () {
  
  Serial.begin(9600);
  mySerial.begin(38400);
Serial.println("Serial");
mySerial.println("mySerial");
}



void loop () {


/*
 serial and mySerial test
---------------------------
if (mySerial.available()) {
  Serial.write(mySerial.read());
  }
if(Serial.available()) {
  mySerial.write(Serial.read());
  }

 */

byte myHex [] = {0xA0,0xF0,0x55,0xFF,0x40,0xBF };
byte myBin [] = {B10100000,B11110000,B01010101,B11111111,B01000000,B10111111};



mySerial.write(myHex, sizeof(myHex));
delay(5000);

mySerial.write(myBin, sizeof(myBin));
delay(5000);

// I tried with and without \r \n after the various mySerial.writes and with various delays
mySerial.write('\r');
mySerial.write('\n');

delay(5000);


mySerial.write(0xA0);
mySerial.write(0xF0);
mySerial.write(0x55);
mySerial.write(0xFF);
mySerial.write(0x40);
mySerial.write(0xBF); 


delay(5000);
}

foxx182:
If I hook up the serial monitor directly to the TV and type in " ðUÿ@¿" and press send, the tv gets controlled successfully.

How do you do that?

What is the line-ending setting in the Serial Monitor?

Is your Arduino program adding the same line ending?

...R

Robin2:
How do you do that?

I can control the TV in multiple ways by sending the command from the PC. In Arduino serial monitor, I hook up a serial cable from the tv to my pc, change the comX to the com port the tv is on. type the code and send it. I send it with "no line ending", baud 38400.

The other way I send it is using a program called realterm. I configure serial, I type the hex in and press send numbers. I get a response back from the tv mirroring the code I sent out (displayed in the realterm window.). then the tv follows the command. code required for realterm is

"0xA0 0xF0 0x55 0xFF 0x40 0xBF" minus the quotes.

Thanks, but you have not answered my other (and more important) question

Is your Arduino program adding the same line ending?

...R

holy moley I was pounding my head against a wall. Robin2, I wasn't sure, that's why I was asking for help =D, again, quite new to the programming. either way, IT WORKS. my first program was the one that worked correctly. The problem was in the max232 chip. max232 -> db9 tx/rx were crossed. What was strange was I was receiving and sending info correctly from a pc to the Arduino with the wires crossed, which made me think it was correct. I ended up checking the voltages of pin 2 and 3 on the db9 and realized they were crossed.

Thank you for the help!

This is my code that works for anyone that would like it!

#include <SoftwareSerial.h>
SoftwareSerial mySerial(10, 11); //rx tx

const int onoff = 9;
int onoffstate = 0;
byte myHex [] = {0xA0,0xF0,0x55,0xFF,0x0B,0xF4 };
void setup () {
  
  Serial.begin(9600);
  mySerial.begin(38400);
  pinMode(onoff,INPUT);
  }


void loop () {
  onoffstate = digitalRead (onoff);
  if (onoffstate==HIGH){
  mySerial.write(myHex, sizeof(myHex));
  }
  }

foxx182:
holy moley I was pounding my head against a wall.

Welcome to the club :slight_smile:

...R