Hey all, I'm very new to Arduino and need some help with a project.
I want to receive 8 bits of binary data on the hardware serial port (9600n2), look and the first 4 bits (it's an ID) to see if it's addressed to us, and if it is then compare the last 4 bits to some known's to decide what the message was telling us to do.
I can handle the latter, but not sure how to wait for the serial port to get 8 bits in the buffer before doing something, then how to store the first 4 in a ID variable and the next 4 in another variable.
Please any help to get me on the right track would be appreciated.
The arduino handles serial communications for you - it delivers the data a byte at a time, so there is no need to worry about waiting for individual bits. You use serial.available to find out if any data has arrived, and if so, serial.read to get it.
Perhaps it's better if I tell you what is happening.
In total there are 10 ID's:
0000
0001
0010
0011
0100
1000
1001
1010
1011
1100
Then the next 4 bits are a binary number 0 through 9 (9=1001 and so forth)
I need the arduino to listen for it's own ID and then store the ascii number into a variable.
After that I'm driving a 7segment display directly from the arduino.
It's kinda like mimicking a 7seg latch driver.
I just don't understand how to get from the binary serial to the point that I have a ascii value stored in a variable.
They are scattered all over a building connected by RS485 (I convert back to rs232 before giving it to the arduino).
The binary data stream originates from a propriety system I can't change.