Difference between revisions of "Bingo Game Machine 04"

From Microduino Wiki
Jump to: navigation, search
(Module)
(Other Equipment)
 
Line 34: Line 34:
 
*Sensor cable*3
 
*Sensor cable*3
 
*Sensor shell
 
*Sensor shell
*Lego or other fixation structures
+
*Building blocks or other fixation structures
 
[[File:anywhere_Bingo game 4-module.jpg|600px|center]]
 
[[File:anywhere_Bingo game 4-module.jpg|600px|center]]
  

Latest revision as of 10:42, 27 March 2017

Overview

Anywhere Bingo game 1.jpg

Optimize the program of position detection, preventing scoring through turning the potentiometer casually.

Module List

Module

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

Other Equipment

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

Module Setup

Setup

Anywhere Bingo game 4-step.jpg
  • Assemble modules and sensors 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;
    • Plug one end of USB cable into the battery base, and connect the other to computer.

Programming

Programming Thought

Other programming thought is same with that of the last course, and a score condition judgement is required, when score is 15, the green LED lights 1s and then goes off, reset score.

Mixly-ctrl-Bingo game 4.jpg

Required Program Blocks

Start to Program

1. Declare variables for storing data

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


2. Victory judgement
Content of function win: if score is 15 (score 15 points), the green LED will light 1s, reset variable score.

Mixly-ctrl-Bingo game4-code1.jpg

3. Function start isn’t changed.

Mixly-ctrl-Bingo game4-code2.jpg


4. Function display isn’t changed.

Mixly-ctrl-Bingo game4-code3.jpg

5. Function BINGO isn’t changed.

Mixly-ctrl-Bingo game4-code4.jpg

6. Function time_out isn’t changed.

Mixly-ctrl-Bingo game4-code5.jpg



Test the result
After upload, display the random number (reproduce it if it hasn’t been aligned in 3s) on the first line, display “1 2 3 4 5 6” on the second line, and display SCORE: 0 on the third line. Move “1 2 3 4 5 6” with the potentiometer. Only after a while from the numbers were aligned can score, the score displayed on the third line will change. When the score is larger than 15, the green LED will light 1s, and then the game will restart.

Anywhere Bingo game 1.jpg



Q: When the Joystick being pressed is detected, the game begins, and the duration time will be displayed at the end of the game.
A: Today we will learn a new program block, which can be executed once at the beginning of the program and be never executed again after that

Start the setup function, wait for the Joystick to be pressed, then the game starts and timeout begins. When the score arrives 15, timeout ends, wait for the Joystick to be pressed to restart the game.

Mixly-ctrl2-Bingo game4.jpg


1. Variable time is for storing the completion time

Mixly-ctrl-Bingo game4-code6.jpg

2. Write the function setup
The function setup waits for the Joystick to be pressed (switch), timer2 begins, for storing the completion time.

Mixly-ctrl-Bingo game4-code7.jpg

3. Change function win
If score gets 15, save the value of timer2 in variable time, divide variable time with 1000 (because the unit of the initial value of time is ms). Display the value of time on OLED. Green LED lights 1s. Wait for the Joystick to be pressed (switch).

Mixly-ctrl-Bingo game4-code8.jpg

4. Function start isn’t changed.

Mixly-ctrl-Bingo game4-code2.jpg

5. Function BINGO isn’t changed.

Mixly-ctrl-Bingo game4-code4.jpg

6. Function time_out isn’t changed.

Mixly-ctrl-Bingo game4-code5.jpg

Technical Specification

Relative Cases

FAQ