ECE 4180: BOP IT
Project By: Olivia Crank, Connor McMahon, Sidhanth Raman, Megha Tippur
Concept
For our project, we were inspired by the childhood game, Bop It. The game dictates and displays commands that the user has to follow or they will lose the game. The four action commands and their corresponding hardware elements are as follows:
Action | Element |
---|---|
Bop It | Pushbutton |
Slide It | Sliding Potentiometer |
Twist It | Twisting Potentiometer |
Shake It | Accelerometer |
The commands are spoken with a speaker and shown on the LCD screen simultaneously. There is a Bluetooth element where the user can choose a difficulty level and can view high scores. There is an SD card that stores the .wav files that are being played during the commands and records the high scores so that they are non-volatile. Our project used 2 MBEDs to power all the components.
Hardware Pinouts and Code
Speaker
MBED | Speaker | Amplifier | |
---|---|---|---|
p18 | - | - | 330 ohm resistor |
Vout | positive | - | |
- | negative | C | |
- | - | B | 330 ohm resister |
GND | - | E |
The voice commands were played on the speaker using the wave_player library. The library opens and plays a .wav file from the SD card through the AnalogOut pin. The prerecorded voice commands and music were stored on two different SD cards for each MBED. The commands were recorded by the team members in Audacity, amplified and resampled, and exported as a .wav file onto the SD card. The following function was written using the wave_player library to play a single file on the SD card.
AnalogOut DACout(p18); wave_player player(&DACout); void playFile(char * filename) { char result [50]; sprintf(result, "/sd/%s.wav", filename); //turn input into a file string FILE *fp = fopen(result, "r"); // opens the file on SD card player.play(fp); // calls wave_player function "play" fclose(fp); } int main() { playFile("bopit"); //plays the file "bopit.wav" on the SD card }
SD Card
SD Card | MBED |
---|---|
CS | p8 |
DI | p5 |
VCC | Vout |
SCK | p7 |
GND | GND |
DO | p6 |
CD | - |
The SD card was set up using the SD Card File System. Each MBED had its own SD card reader to play .wav files. The SD card was also used to record the high scores.
Bluetooth Module
MBED | Bluetooth Module |
---|---|
GND | GND |
Vu | Vin |
GND | CTS |
p27 | TXO |
p28 | RXI |
- | RTS |
The Adafruit Bluefruit LE Connect application was used to interface directions and high scores using UART. The user starts the game and connects his or her phone to the BOP IT. The directions for the game are printed to the phone screen, and the player is asked to input his or her name and difficulty level. The Bluetooth communicates through Serial TX and RX connections with the Mbed, receives the serial data, and save’s the name. When the game is over, the user is asked whether or not they want to restart the game using the same Serial method above. In order to save the high scores even after the Mbed has been reset, a text file saves the names and high scores of the players from previous games on an external SD card. After a player has completed a round, the top five high scores are read from a text file, and pushed into a Vector object. When the game is done, the player’s final score is added to the vector, sorted, and printed on the cellphone. Additionally, the updated names and high scores are rewritten to the text file.
Twisting/Sliding Potentiometer
MBED | Twisting Pot | Sliding Pot |
---|---|---|
p19 | 2 | - |
p20 | - | 2 |
Vout | 1 | 1 |
GND | 3 | 3 |
The twisting potentiometer is used for the Twist It game scenario and the sliding potentiometer is used for the Slide It game scenario. They both take in 3.3 V from the mbed power rail. They are read by the mbed as analog inputs and use the standard mbed library.
Accelerometer
MBED | Accelerometer |
---|---|
p9 | SDA |
p10 | SCL |
Vout | 3.3V |
GND | GND |
The MMA8452 accelerometer is used for the Shake It game scenario. It takes in 3.3 V from the mbed power rail. It reads change in the x,y, and z directions through the SDA and SCL channels, and uses the MMA8452 library.
Pushbutton
MBED | Pushbutton |
---|---|
p21 | 1 |
GND | 2 |
The pushbutton is used for the Bop It game scenario. It is read by the mbed as a digital input and uses the standard mbed library.
LCD Screen
mbed | uLCD Header | uLCD cable |
---|---|---|
Vu | 5V | 5V |
GND | GND | GND |
P13 | RX | TX |
P14 | TX | RX |
P11 | Reset | Reset |
The LCD screen was used to display the commands along with the speaker and used the 4DGL-uLCD-SE library.
Total Pinout
Total Pinout (Power and Ground Not Shown)
Implementation
The final product requires the user to begin the game by connecting their smart phone to the device via Bluetooth. During the setup process, the user is prompted for their name, difficulty level, and a random number (used to seed the random number generator that selects the command). Once the game begins, a command is randomly selected and is announced through the speaker and displayed on the uLCD screen. The user has a limited amount of time to complete the task, and will gain one point with each correct action. The time limit increases with every completion of the task. When the difficulty level is higher, the time limit will decrease faster. If the user does not complete the task within the time limit or they perform the wrong task, the game is over and the updated high score board is displayed on their phone. When the game is complete, the user will be asked if they would like to play again, and the device will respond accordingly.
Encasing
A holding box was 3D printed to hold the final product. The box encloses the wiring and only leaves the interactive components exposed for the user to play.
Final Product
The final product can be downloaded below:
Import programECE_4180_FINAL_PROJECT
Final Project - Bop It
A demonstration is seen in the video below.
Please log in to post comments.