I created a p5 sketch that takes in the reading of potentiometer and map it to the value of the sizes of the pedal from 0 to 10. The theme is to mimic the game of plucking flower petals when people are unsure about if the person they have a crush on love or does not love them.
Check my code here.
I created two version of this game. One is for ICM and one is for PComp. The one for ICM plays around with mouse position and loading music. You can see the documentation here.
I want to use the potentiometer for PComp. Therefore, I used the data from potentiometer to control the size of the petals and the number of the petals.
Procedure involving Arduino, P5.Serial Monitor, and P5.js
I spent a lot of time debugging cuz it shows undefined when I try to print out sensorValue. Also, sometimes it gives out a warning of the “something undefined”. I now concluded the steps of using everything together.
- Upload Arduino
- Close Arduino’s serial monitor
- Turn on the p5 Serial Monitor Application – No need to open and connect the board
- Turn on p5 js
Labs somewhat confusing
The labs are good in a way it walks me through the important steps. However, some of the code lines are confusing. I tried to put the code mentioned on the lab in my sketch, it didn’t work. Then I went to the github and copied everything, it worked. I fear maybe there are some lines neglected on the lab instruction. But I am happy that everything works and I can use potentiometer to control the flow of the sketch.
Why do we learn node.js?
Also, the labs on node.js and creating the host website so that other device can display the sketch is quite helpful. However, I am not sure why we would include node.js if we can just use terminal to write python -m SimpleHTTPServer to create a host for our project. I am quite confused by the meaning of learning node.js.
I remember I had troubling doing the lab for node.js and it shows up as below where it gives me a type error that SerialPort is not a constructor. I then searched on Github and typed several commands and then I can use the serial port.
It is fun to connect everything we have learned so far together. It feels quite rewarding to create something and control certain parameters using sensors.