Serial Input/Output to P5

Serial Input

Serial input lab went smooth sailing — I was able to follow every step with appropriate results coming back to me. I enjoyed being able to control what is on the screen with a physical sensor, and it reminded me of the alarm clock that I made for sensor research. Below are the videos from the lab instructions I followed: 

The only ‘problem’ I had with the input lab was the instability of the potentiometer. The one that I had did not stay still on my breadboard, so I had to angle it in an odd way and hold it down while I turned the knob. Next time, I think it’d be best for me to solder and use the wires instead. 

SERIAL OUTPUT

While following the instructions, I ran into the problem of not being able to light up the LED through p5.js. I wasn’t sure if it was a wiring problem or my code problem (or maybe the LED was a nonfunctional one?), so I went ahead changed my Arduino to a very simple code. Below shows how I dashed out what I had before from the lab, and my new code that would just light up the LED when uploaded. 

After I uploaded this code to my arduino, my LED light up! So it was clear that the problem of controlling the LED through p5.js was in my code. Below shows the LED lighting up after I uploaded my simple code. 

In order to debug, I went to the complete code example that was linked on the lab to compare what I had on my screen versus the correct coding. After examination, I realized that I did not switch the port name to my serial port, which was COM6. 

Below is the link to the video that shows my LED being controlled by either the numbers or the mouse. 

https://drigve.google.com/file/d/1EkQJXRVRjCN9SPgNrWCm1dxlaZQHWFiW/view?usp=sharin

Then, below is link to the video that shows my LED being controlled by either typing ‘L’ or ‘H’ on the arduino serial monitor. 

https://drive.google.com/file/d/19E8ycUDs7c-juF44IMWy26pzoX0jOSKT/view?usp=sharing

Then, below is link to the video that shows my LED being controlled by either typing ‘L’ or ‘H’ on p5.js

https://drive.google.com/file/d/1iTz0h2XvZ3zF8-kUsWfh7fEmcozwkHwV/view?usp=sharing

I had the problem of p5.js not being able to read println, but once I switched println to console.log, the issues were resolved. 

In addition, I did not realize that I could use a spacebar to seperate each ASCII numbers. Before this realization, I was sending each letter seperately every time to form a word. Below is my wonderful creation, “JIWON.” 

Leave a Reply

Your email address will not be published. Required fields are marked *