Keer Zhao
Intro to Physical Computing



Lab:Two-Way (Duplex) Serial Communication Using An Arduino and P5.js

Setup with one digital input and two analog input
This week's lab is very similar to what we did last week.
Mainly, the Arduino codes are the same with one pushbutton input and two rotary encoders as analog input.
In total three readings are transferred to P5.js as paraments for the circle's movement on the sketch.

Wrong connection of the digital output of the pushbutton

Corrected connection

Testing
Improved coding with 'handshaking' method

Codes are then improved by using the 'handshaking' method. Simple the sender side (Arduino) will only send the data when requested. P5.js plays as the requestor, to add for one set of data to come in once the previous set is sketched.
However, I ran into the same problem as last week: every time I request new data, I always get two sets returned (shown below).

