Circle Slide Game
For this project we had to create an enclosure with different sensory inputs that corresponded to different outputs using P5 and Arduino. Here I will show you how I made a game where you use a button, slider, and a potentiometer to direct a moveable cirlce into a square goal.
Supplies
Arduino Nano
Lazer cutter
Potentiometer
Button
Slider
Small breadboard
Jumper wires
Solder
Hot glue
Enclosure
First, I created a box in Illustrator that was 5x5x5 with openings for the button, slider, potentiometer, and LED. After sending the file to the laser cutter, I partially assembled the box. I then installed the button, slider, potentiometer, and LED to the top part of the box. The top should be one of the parts assembled last so that you can more easily solder wires.
Next, I connected the Arduino Nano 33 IoT to the breadboard with one free remaining row. I then connected a yellow wire in the free row to power on the Arduino, second from the top left pin. Then I connected the outer pins of the potentiometer using solder to power and ground and the center pin to A1. Following, I connected the singled out pin on the slider to ground and the perpendicular pin to A0. Then the pin directly below was connected to power on the free row. The short left of the LED was connected to ground and the long leg was connected to power. On the button, I connected one of the two adjacent pins to power and the singled out pin was connected to a resistor that was connected to ground and a signal pin was connected to D2.
Code
Next I added the code found at this link into Arduino.
https://gist.github.com/ramerame13/a3aa18149dc3647...
And finally, when moving the slider and potentiometer, which controls the x and y movement of the circle, you can navigate the circle to one of the two squares or "goals". Once aligned perfectly, the circle should disappear. The code is still a work in progress. I had hoped that once the circle fits into the square, it would disappear and a new circle can be produced by the push of the button.