physical computing(week7)



Before doing the lab of class 7, I did the lab of class 6 again. Because I thought that I did not fully understand the knowledge of class6.

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

I met many problems when redoing the labs, most of them were solved through reading the syllabus and rebuilt the circuit over and over again. However, there was a bug that cost me A LOT OF time and actually was very easy to solve. By checking the code line by line, with the help of Echo, I finally found the bug!Although it was a stupid mistake, I think it is necessary to record it and share it with all of you who are reading the blog. I hope you won’t waste any time because of this mistake.

I followed the instructions in the syllabus and input the exact same code into the p5 editor, but “sensor value: undefined” was always displayed on the screen, which means that inData is not defined.

I checked all the code and reuploaded every file, but still didn’t found the reason. Then Echo sent me her code, I checked and replaced all of my code line by line with hers, and finally found that the error was at the beginning! I typed an extra space in the place of portName! This may cause the serial has no data source (did it?)

Anyway, it took me a lot of time to debug. I’m sharing it here. Hope you will not make similar mistakes.

Based on redoing last week's lab, this week's lab went smoothly without any particular tuff problem.


There is also another weird situation, that the number of “sensor value” is a negative number, and it won’t change at all. Meanwhile, the value did show in the console, and number of it change in the correct way. Really wonder what causes this.