Bingo Game Machine 05

From Microduino Wiki
Jump to: navigation, search


Anywhere Bingo game 1.jpg

Improve the game machine, implementing the function of storing the top record.

Module List


Module Number Function
mCookie-Core 1 Core board
Battery base 1 Program download and power supply
mCookie-Hub 1 Sensor adapter plate
mCookie-OLED 1 Display
Potentiometer 1 Detect rotation
Buzzer 1 Produce sound
ColorLED 1 ColorLED
Joystick 1 Equivalent to the gamepad, to input control

Other Equipment

  • USB cable*1
  • Sensor cable*4
  • Sensor shell
  • Building blocks or other fixation structures
Anywhere Bingo game 5-module.jpg

Module Setup


Anywhere Bingo game 5-step.jpg
  • Assemble modules and sensor together:
    • Stick the red core module, battery base, OLED and green Hub together;
    • Connect the Buzzer to pin 8/9 of Hub;
    • Connect the Potentiometer to pin A0 of Hub;
    • Connect the ColorLED to pin 6/7 of Hub;
    • Connect the Joystick to pin A2 of Hub;
    • Plug one end of the USB cable into the battery base and connect the other to the computer.


Programming Thought

Add the code of storing the top record and comparison, and other programming thought is same with that in the last course. At the beginning of the game, the top record is displayed. At the end of the game, judge whether the top record is broken, if it is, it will be updated.

Mixly-ctrl-Bingo game 5.jpg

Required Program Blocks

Start to Program

1. Declare variables for storing data
Variable top is for storing the top record

Mixly-ctrl-mixly-ctrl-Bingo game5-code.jpg

'2. Function setup
Change the setup function into: save the value in 0 of the EEPROM address into top. Display top on OLED.

Mixly-ctrl-Bingo game5-code1.jpg

3. Function win
Change the content of function win into: If the score reaches 15, compare the duration time to the top record, if time is less than top (the record is broken), on the OLED will displayed “you are the best” and the score. Save time into the address 0 of EEPROM (update the record) and play the music for celebration. Otherwise only display the score and the green LED lights 1s.

Mixly-ctrl-Bingo game5-code2.jpg

4.Funcation start is unchanged

Mixly-ctrl-Bingo game4-code2.jpg

5.Function display is unchanged

Mixly-ctrl-Bingo game4-code3.jpg

6.Fucntion BINGO is unchanged

Mixly-ctrl-Bingo game4-code4.jpg

7.Function time_out is unchanged

Mixly-ctrl-Bingo game4-code5.jpg

Test the result
After upload, on OLED will display the top record, press the Joystick then the game begins. The random number will be displayed on the first line and it will change once each 3s. “123456” will be displayed on the second line, and SCORE: 0 will be displayed on the third line. Turn the potentiometer to move the “123456”, after a period of alignment can it score, the score displayed on the third line will change. When the score reaches 15, if the duration is shorter (breaking the record), on OLED will “you are the best” and the score be displayed, and it will play the music for celebration, otherwise, only display the score and the green LED lights 1s. Wait for the Joystick to be pressed to restart the game.

Anywhere Bingo game 1.jpg

Q: In the address where we store the top record of EEPROM maybe there data stored a long time ago, so we need the function of clearing the top record directly for the game.
A: We can write a larger time value in it to replace the smallest one.

Based on the programming thought of Bingo04, add the program of clearing the top record

Mixly-ctrl2-Bingo game5.jpg

Add function clear
If the Joystick is turned to left, write 99 (99s, a very slow speed. If your write o, it won't be beaten forever), display “clear top” on the OLED and blue LED lights 1s.

Mixly-ctrl-Bingo game5-code3.jpg

Execute the functions

Mixly-ctrl-Bingo game5-code4.jpg

Technical Specification

Relative Cases