Lab: Two-Way Serial Communication Using An Arduino and the p5.webserial Library
Preparing the Breadboard
Sending Multiple Serial Data using Punctuation
-> I was able to confirm that turning the two potentiometers displayed each value on the serial monitor, and pressing the button showed “1” while not pressing it showed “0” on the serial monitor.
Receive the data in P5.js
-> Is this correct method if I entered it as shown in the photo on the right? 🤔
-> I entered all the code, but it didn’t work. I wondered if I had entered something incorrectly, so I tried copying and pasting the entire code, but it still didn’t work. I have no idea what the problem is, and it’s frustrating. Turning the potentiometer doesn’t cause any changes in the p5.js sketch, and the push button doesn’t work either. -> I confirmed that both the potentiometer and push button are properly connected and working on the Arduino serial monitor 😭
Arduino IDE was not closed...
Now perfectly ingrained in my brain. -> Now it works...
Flow Control: Call and Response (Handshaking)
-> “Hello” appears on the serial monitor, and as soon as I type any word into the input field and send it, I was able to get a string of sensor values at the end of the hellos. -> Each time I entered a new word in the input field and sent it, I was able to confirm that the sensor values were updated on the serial monitor immediately after the transmission.
Modifying the P5.js Sketch
-> The previous lab connecting to p5.js didn’t work properly, so I anticipated that this one wouldn’t work either—and as expected, it didn’t. Again, while the potentiometer and push button were properly connected and functioning, there was no change visible in the p5.js sketch.