Serial Communication through RX TX to a Card Dispenser

Hello everyone,

I am trying to create a coin changing machine that will have multiple functionalities, one of each is dispensing a card if the user introduces a certain amount of money.

I have managed to establish communication between the bill validation and Arduino, but now I am having a difficult time figuring out how to communicate with the card dispenser.

I am using a CRT-541. Manual can be found here - page 15 - Multi Unit Communication Setting.(Model that uses RS232 interface).

I have connected the RX, TX and GND to the Arduino via jumper cables.
RX to Digital Pin 0, TX to Digital Pin 1 and GND to GND.

The multi switch is set to address '15' as per data sheet. Also, I am using an Arduino UNO R3 ATMega328P.

I have tried to communicate with the Arduino using following code:

#include <SoftwareSerial.h>

SoftwareSerial mySerial(0, 1);
char STX,HByte,LByte,HCmd,LCmd,ETX,BCC;
void setup() {
  Serial.begin(9600);

  STX = 0x02;
  HByte = '1';
  LByte = '5';
  HCmd = 0x44;
  LCmd = 0x43;
  ETX = 0x03;
  BCC = STX ^ HByte ^ LByte ^ HCmd ^ LCmd ^ ETX;
  mySerial.write(STX);
  mySerial.write(HByte);
  mySerial.write(LByte);
  mySerial.write(HCmd);
  mySerial.write(LCmd);
  mySerial.write(ETX);
  mySerial.write(BCC);
}

void loop() { 
}

I have never used RS232 to communicate to a device before so, I am sorry in advance if this is a stupid question, but I really don't have any idea on how I should manage the situation. I have tried to search on the internet before but I haven't found anything useful. Do you guys have any idea how I should fix the problem?
Thank you all again for the time reading this question :slight_smile:

SoftwareSerial mySerial(0, 1);
void setup() {
  Serial.begin(9600);

You should NOT use pins 0 and 1 for both Serial and SoftwareSerial.

The Arduino uses TTL (5V) serial. Your device uses RS232 (+/-12V) serial. You will need a level converter to get the two devices to talk. Like this one: https://www.ebay.com/i/223589266100

if this is really RS232 (+/-12V) then your pin 0 might be dead...

Thank you guys for letting me know. I will buy the module and see if it will solve the problem.

One more little question: Was the way i sent the data to the card dispenser correct? Or should I use another approach?

Hi - writing bytes is OK. (might use the byte type rather than char as it's a binary protocol but won't impact how this works)

You need to listen to the response, I would suggest to study Serial Input Basics to handle this

Got it. Thank you both for the responses!