Arduino to p5.js - GitHub Gist Code - p5.js Code
Two potentiometers were used to communicate with the p5.js canvas through the p5.serial control monitor. The first potentiometer was used to translate an ellipse along the x-axis, while the second analog input changed the size of the ellipse.
p5.js to Arduino - GitHub Gist Code - p5.js Code
When the mouse is clicked on the p5.js canvas, then the LED lights up. When the mouse is let go, the LED turns off.
Fruit Ninja - GitHub Gist Code - p5.js Code
To visualize the interaction between Arduino and p5.js, I created a game of Fruit Ninja. For the analog input, I used a joystick, which is essentially two combined potentiometers, one for the x-axis, and one for the y-axis. The joystick's x and y values are read through the p5.serial controller and are mapped to the knife you use to chop the fruit in game to increase your score. But be careful! When you hit a bomb, you lose a life, which is communicated from p5.js to the Arduino board to turn off one of the LEDs representing the number of lives you have. When you run out of lives, the game is over.
Back to Top