P Comp

Cube Switch Game Update - Code Is complete

The code and the circuit for the game is complete. We only need to fabricate the cube and run the Arduino wirelessly using Bluetooth. The game starts by hitting the start button all the way on the right. The user must hit the button of the corresponding LED within the allotted time. This amount of time shrinks with each button press until the user loses, at which point all the LEDs will flash.

The added timing components make use of the millis() value and creating time stamps. The interval of time for the user to hit the button starts at 10 seconds and then decreases by 20% each time the next button is hit. This is better than decreasing the time by a full second so it never goes negative and provides a greater challenge to the player.

There are some things printed to serial using "Serial.print()" so we can use p5 to create special sounds for each button and also when the player loses. The Arduino will send information about how long the time interval is and which button was pressed. The p5 code then uses that to play a sound for each button. The video is above, and the Arduino and p5 code is below.


p5.js CODE