The project was to use the Circuit Playground Express along with a Potentiometer and a Switch in order to make a creative project that utilizes both the switch and the knob. I decided to make a mini retro arcade machine that has a simple game housed inside of it. I used Microsoft MakeCode for this project.
It works first off by reading the switch input. If the switch is flipped in one way, the rest of the code can function, if not then a power down noise is played and nothing works. The game works by reading the potentiometer input, mapping it from 0-9 (to represent the 10 neopixels) and then flooring that map so that it only results in whole numbers. Also, a function is called on start to also choose a random number between 0 and 9 that is also floored in order to give a whole number that is set as the "goal". Another function is used in the forever loop in order to constantly check if the cursor (the potentiometer input) matches with the goal, and if it does, it plays a sound, plays an animation, and calls the goal setting function once again, effectively restarting the game. The clear command is also constantly running in order to have the cursor not continuously light every neopixel it passes over.
Comments
Please log in or sign up to comment.