first of all let me thank you all , you have been of great help. So, my problem is the next , i have note counter machine i need to read the data from the machine to the arduino , as bytes or ascii , just some readble data . The machine is connected on the arduino via 2 pins , tx and rx and the data i am getting is not readble and kind of wierd , and one more question do i need some kind of serial shiled or no ?Because right now it is connected with just 2 wires . Thank you
#include <AltSoftSerial.h>
// AltSoftSerial always uses these pins:
//
// Board Transmit Receive PWM Unusable
// ----- -------- ------- ------------
// Teensy 3.0 & 3.1 21 20 22
// Teensy 2.0 9 10 (none)
// Teensy++ 2.0 25 4 26, 27
// Arduino Uno 9 8 10
// Arduino Leonardo 5 13 (none)
// Arduino Mega 46 48 44, 45
// Wiring-S 5 6 4
// Sanguino 13 14 12
AltSoftSerial altSerial;
void setup() {
Serial.begin(9600);
while (!Serial) ; // wait for Arduino Serial Monitor to open
Serial.println("AltSoftSerial Test Begin");
altSerial.begin(9600);
}
byte rx_byte =0 ;
char text ;
char hex;
void loop() {
if (altSerial.available()) {
// get the byte from the software serial port
rx_byte = altSerial.read();
// send a byte to the software serial port
//altSerial.println(text);
Serial.print(rx_byte, HEX);
}
//Serial.println("TUKA SUM");
//text = altSerial.read();
//hex=(text);
//Serial.print(text);
//Serial.write(text);
// Serial.println(text);
-
What is the code? And what is the weird output?Michel Keijzers– Michel Keijzers2018年11月14日 12:05:25 +00:00Commented Nov 14, 2018 at 12:05
-
Please provide a link to the note counter you are using.Majenko– Majenko2018年11月14日 12:07:24 +00:00Commented Nov 14, 2018 at 12:07
-
Why are you using soft serial and not 'hardware' serial? What is the output? And are you sure 9600 is the correct speed?Michel Keijzers– Michel Keijzers2018年11月14日 12:07:37 +00:00Commented Nov 14, 2018 at 12:07
-
AltSoftSerial Test Begin 00FE0F00000000000000000000000000000140B50000000000000000009C0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000083000830000B4AFB400002F90008000007F0042000091000E700E2FF00000F001E00FE0080000000000007DFC00F0000000008000FFIvanh23– Ivanh232018年11月14日 12:08:51 +00:00Commented Nov 14, 2018 at 12:08
-
This is what i am getting , and link is souqmega.com/product/nc3500-ma-value-counting-machineIvanh23– Ivanh232018年11月14日 12:10:01 +00:00Commented Nov 14, 2018 at 12:10
1 Answer 1
The 9-pin port is designed for connecting to a printer. It uses the RS-232 protocol, not UART.
You cannot connect it directly to an Arduino - you must connect it via a MAX232 adaptor board.
Disconnect the cable immediately - the voltage levels of RS-232 are likely to do permanent damage to the Arduino.
-
Yeah i saw it somewhere , i disconeteced it , so in conclusion there is no way just two wires from serial cable to tx and rx on arduino ?Ivanh23– Ivanh232018年11月14日 12:53:37 +00:00Commented Nov 14, 2018 at 12:53
-
Nope. You need to transform the voltage levels from -10V/+10V to +5V/0V.Majenko– Majenko2018年11月14日 12:54:24 +00:00Commented Nov 14, 2018 at 12:54
-
So without MAX232 adaptor board i can do the thing i want , Okey , thank you a lot .Ivanh23– Ivanh232018年11月14日 12:56:05 +00:00Commented Nov 14, 2018 at 12:56