Week 8
|

This week, we learned about one-way serial communication between the Arduino and p5.js.

Arduino to p5.js
I started out with following the lab and making the graph with a potentiometer. I noticed that even though I had the potentiometer value mapped from 0 to 1023 to 0 to 255, I wasn’t able to get the sketch to accurately represent the numbers:

After adjusting the IDE code as well as the serialEvent() function in p5 to read ASCII data, the data transferred much more smoothly. The graph ended up mapping accurately to the potentiometer reading:




p5.js to Arduino
This lab was really helpful for me to understand more about the differences between ASCII and binary. I noticed that in binary, the code is a bit easier to write, but the data transmission isn’t as smooth:



In contrast, with ASCII readings, the data reads much more smoothly, which I noticed in the first lab as well.