I want to connect a barcode scanner with Arduino. I used MAX232 to convert the levels. I have taken only 3 pins: 2(RX), 3(TX) and 5(GND) from the DB9 cable and given them to pins of MAX232 as shown in the figure:
This is the code written in Arduino:
#include <SoftwareSerial.h>
SoftwareSerial mySerial(6, 7); // RX, TX
void setup()
{
Serial.begin(9600);
pinMode(6,INPUT);
pinMode(7,OUTPUT);
mySerial.begin(9600);
}
void loop()
{
if (mySerial.available())
Serial.println(mySerial.read());
}
When I move the TX pin on DB9, I get readings like 255, 240, 189, etc., i.e. random numbers. However, when I scan the barcode, I am not getting any output. I also checked the output of TX pins on an oscilloscope, which showed symmetric waves for a very short amount of time. Again, when the pin 12 of MAX232 (TTL output) was connected to the oscilloscope, no reading was observed.