Hi,
Im struggling with a problem, and hope someone can see what im doing wrong.
I have a unit sending out when reading with hyperterminal "$DF158,33,Q4,D"
And i try to read this and sort out the position digits "158" and resend as "%158", the 158 can be anything from 001 to 360, depending on input. My code so far is as below, but my output is really not good, just garbage, not as i wanted %XXX.
Hope anybody out here can se what im doing wrong.
Br
Patrik
void setup()
{
mySerial.begin(4800); //out
Serial.begin(4800); // in
}
1. You have a UNO with which a HyperTerminal is connected via software UART Port named -- mySerial(SRX, STX). Is this correct? if so, what are the numerical values for SRX pin and STX pin?
2. You are receiving this string from HyperTerminal: $DF158,33,Q4,D. Is it correct?
3. Now. you want to catch 3-digit after $DF and then you want to send this string to Hyper Terminal: %158. Is it correct?
if the input is terminated with a known character such as a linefeed, Serial.readBytesUntil() can be used to read a complete line and sscanf() used to extract the numeric value from with the string
Hi,
Thanks for the answer, the Myserial is pin 2 and 3, the "$DF158,33,Q4,D" is the data from hyperterminal, i connected laptop to the unit to see what type of data that will come out and will be sent to the ARDUINO. So basically, what i try to do is to take this "$DF158,33,Q4,D" and extract the three digits after the "DF" letters, add a "%" and send it out again on another serial. But all i get is garbage on the output.
Is your DF Unit connected with UNO? Can you see the string $DF158,33,Q4,D on the Serial Monitor of UNO? If yes, please post your sketch that you have uploaded/executed.
Note: If DF Unit is a RS232 device, then you cannot connect it directly with UNO risking your UNO to be fried. You need a RS232/TTL converter.