Perhaps tell us what device is sending the data. An RF module? Something else?
If it is another chip using Great Cow Basic then please post that code as well.
Is the sending device actaully sending a "1" (ASCII 49) or is it sending a byte value of 1 ?
I suspect the sending device is sending ASCII strings. For example, sending a value of 149. it actually sends three bytes. (49, 52, 57). Or if sending a vale of 33, it would send ( 51,51).
HserReceive only receives 1 byte.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Yes, I agree with William, You are sending an ascii char and comparing it to an ascii char "1". So when you send a "10" it actually sends a "1" and a"0", two chars.
An alternative is to use the command "HSerGetNum myNum". It will put input a number from the sending device in the range of 0 to 65535 (word size). The command checks that only numbers are input disregarding other characters while waiting for the ending <cr>.
So you would send "1", <cr> which is like 1 and "enter key"
OR "1", "0", <cr>....... 10 enterkey
OR "1", "4","9",<cr>....... 149 enterkey</cr></cr></cr></cr>
See the help files under the "cow with a question mark on" in the tool bar.
command references>serial communication>RS232(hardware)
Good Luck
Mike
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Hello,
I have a problem with HserReceive
Example:
HserReceive Value
If value = "1" then Set LED on
if value = "0" then Set LED off
This code works well with numbers from 0 to 9
Numbers greater than 10 already have a problem.
Detail:
The LED lights up with values from 10 to 19 and from 100 to 199, that is, the HserReceive only reads the first digit
The same happens with letters, the HserReceive only reads the first letter
Need more info.
Perhaps tell us what device is sending the data. An RF module? Something else?
If it is another chip using Great Cow Basic then please post that code as well.
Is the sending device actaully sending a "1" (ASCII 49) or is it sending a byte value of 1 ?
I suspect the sending device is sending ASCII strings. For example, sending a value of 149. it actually sends three bytes. (49, 52, 57). Or if sending a vale of 33, it would send ( 51,51).
HserReceive only receives 1 byte.
Yes, I agree with William, You are sending an ascii char and comparing it to an ascii char "1". So when you send a "10" it actually sends a "1" and a"0", two chars.
An alternative is to use the command "HSerGetNum myNum". It will put input a number from the sending device in the range of 0 to 65535 (word size). The command checks that only numbers are input disregarding other characters while waiting for the ending <cr>.
So you would send "1", <cr> which is like 1 and "enter key"
OR "1", "0", <cr>....... 10 enterkey
OR "1", "4","9",<cr>....... 149 enterkey</cr></cr></cr></cr>
See the help files under the "cow with a question mark on" in the tool bar.
command references>serial communication>RS232(hardware)
Good Luck
Mike
William and Mmotte,
I using atmega328p
not send in ASCII.
Ex:
Send 49
Receiver 4
Receiver 9
I using corrent version of GCB.
HserReceive ten
HserReceive one
Value = ten * 10 + one
Will that work?