top of page

Project Display: 

 

Project Brief: 

We're connecting Arduino with one of our previous p5js sketches for this week's assignment. In my case, I choose to create a controller with Arduino's switch, potentiometer, and photocell. 

I first create circuits with all 5 buttons. The breadboard is crowded, so I manage a little bit of the position of each button as the image showed below. 

Setting up input pin in Arduino. Instead of println, I use print to print out data in a line with commas, later split them into an array so that I can use multiple of them at one time in p5js. 



 

I mapped out the potentiometer value into my map x, y size so that users can use it to play. 
I also mapped out the buttons made by photocell into a smaller range. This will prevent some accident touch. 

For the mode-switch button, I created an Array with all modes (default, easy, medium, and hard), and use the global variable J to store a number. Whenever the user taps the button to switch mode, J + 1, the mode will change and will display the current mode on the top left. 

Replacing mouseX, and mouseY of posX and posY for the crosshair. And when the user tap on the button, set boolean isFired = true, and using the detect(x, y) and splice() to splice the enemies. 

Same for the reset button, when the user tap on the button, set boolean isReset to true then run the reset. 




 

Project Display: 

 

bottom of page