• Jane Meng

PCOMP 007

Updated: Jan 12

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 the 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 rebuilding 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 re-uploaded every file, but I still didn't find the reason. Then Echo sent me her code; I checked and replaced all of my code lines 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. I hope you will not make similar mistakes.


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




Question:

Another weird situation is that the number of "sensor values" is negative, and it won't change at all. Meanwhile, the value did show in the console, and a number of its changes correctly. Wonder what causes this.

0 views0 comments

Recent Posts

See All