Networking

01

This week, I wanted the two boards I made the previous week to communicate with each other. Since it is related to my final project, I want to know how the two boards can communicate through serial. Luckily, One board which is my first board, has LED components, so I decided to use that board to communicate with the Sonar distance sensor board.
First, I don’t know where to start. I don’t have any coding experience. So I start with learning how the serial code works using my first board
TAs help me to understand how the serial code works. So using my first board, I write a simple code; if I press “a,” then on the serial print, “hi, you have pressed a”
And then, I wrote two codes for each board: the receiver code for the LED board and the transmitter code for the distance sensor board. But both of the codes didn’t compile. I kept getting an error message which I don’t know.
First, I figured out I didn’t correctly write the distance formula. So I added them. Also, messages for serial write should be shorter, such as “a” or “b,” Instead of “turn on” and “turn off.”
In addition, I changed the variable to ensure the LED was on/off. Instead of If the [distance is =10, Led turn on and else if the distance >=10 & <20, Led turn off ], I change the variable to [distance>=0&<10, Led turn on and else if the distance >=10, Led turn off ], Finally I successfully compile two codes.
I found one more problem when I try to connect two boards. Two boards used different types of pins for the serial. To connect them, I had to make a connection wire.
So I made a special connecting wire using jumper wire and converter.
Finally, I could connect two boards successfully.
It was working. However, Led weirdly kept blinking.
TA Antony’s help, we found that message that the transmitter board was sending was “Distance 10 cm” rather than a clear message10. That's why Led kept blinking. So we revised the code to send messages clearly.
I programmed each board again with new code and connect them.
And successfully it was working!!