top of page

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

WechatIMG1811.jpeg

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.

18171635283155__edited.jpg

Wrong connection of the digital output of the pushbutton

18181635283156_.pic.jpg

Corrected connection

ezgif.com-gif-maker.gif

Testing

Improved coding with 'handshaking' method

WechatIMG1706.jpeg

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).

WechatIMG1813.jpeg
WechatIMG1816.jpeg
Hey Jeff, I add this section for you to leave any suggestions or comments. NO PRESSURE, you don't have to leave something : )

bottom of page