Hello Readers,
I have got a question to you,
How can the AT328 or AT168 receive a binaric word made of 8 bytes that sent from the RS-232, the serial port of the computer (COM port)?
What I want to do is to send a word to the AT328 or AT168 from the serial port (for example: 01001100) and accordingly to what I defined in the program (specific word will cause the processor send "0" and another word cause it to send "1" logic) make the processor sending "1" or "0" from one of his outports.
all of that is for controlling engine to move forward or backwords or not to move at all according to the word was sent from the COM port.
By the way, the engine works on three outputs: VCC and two GNDs. when I take the VCC and the first GND it moves forwards, when I take the VCC with the second GND, it moves backwords.
It's easier to determine how to do this if you do two things. First, understand and use proper terms. Words are a Microslop invention. Everyone else uses bytes and bits. It looks like you want to send an 8 bit value. That's one byte.
Second, show the sending code.
If the sender is indeed sending an 8 bit/1 byte value, one call to Serial.read() will read that byte.
well, first thanks for the help.
Secondly, I don't think I will use all of the combinations of the byte, but these 8 bits are what I have, nothing less or more...
Correct me if I'm wrong.
well, I want to define few binaric words and when I receive one of them from the serial port, according to my desicion, a specific device will start to work. this will happen with everyone of the 9 words I'm going to define in a program on the computer.
For example if this is part of what I defined:
01100100 - X move forwards
01110100 - X move backwords
01000100 - X doesn't move
so when the AT328 gets the first byte, it's gonna move the engine forwards, when it gets the second byte, it's gonna stop from moving and so on...
what do you think about that?
(That's mean I will have 9 words to control the engines, 3 for each engine)