Introduction to Physical Computing / Week 6 / Asynchronous Serial Communication
Week 5 was concentrated over revising analog and digital input and output. Last week, we begun using asynchronous serial communication.
While working with serial communication, there were some things that have to be kept in mind. Firstly, in order for two devices to communicate serially they should agree on three things.
- Baud Rate – The speed at which the two devices send information ( generally 9600 bits per second between a computer and an Arduino microcontroller )
- The logic – The interpretation of high and low voltages. This can be simple logic or inverse logic ( as can be found in RS232)
- The connections – Microcontroller’s transmit line connects to the port’s receive line, the port’s transmit line connects to the microcontroller’s receive line, and microcontroller’s ground connects to the port’s ground.
This week’s lab was focused around reading analog input’s from a potentiometer, and using the input to interact serially with an application. Such as the Serial monitor, CoolTerm or P5. As demonstrated in the class, I used the analog input to move a circle horizontally in P5.
Post this lab, I was trying to run a code where in three analog input’s are read and printed out as a string on the Serial monitor. However, my P5 window was still running while I was working on this code. This led to unexpected results on the Serial monitor. After a while I realized what was happening. So, it’s very useful to remember that the USB port can interact with only one application at a time. Having multiple applications trying to read serial data from the microcontroller will lead to an erroneous output.