"It’s Here! The BFCM Sale of the Year – Grab Your Favorites!"

Memory Test Game

Purpose

This is a small game that tests memory. It will display five characters in a row, and then wait for key input. When the player presses the keys in the correct order, √ is displayed. If the key is entered incorrectly, × is displayed and the game restarts. This is a simple game and you can have a try of optimizing and increasing the difficulty on the basis of this game.

Materails

micro:bit x 1

Nezha expansion board x 1

Push-button brick x 1

RJ11 wire x 1

Bricks x n

Hardware Connections

Connect the servos to S1 and S2, and the Laser sensor to J1 port on the Nezha expansion board.

Software Programming

Go to MakeCode editor:(https://makecode.microbit.org/#editor) Click “Advanced” in the drawer to see more choices for adding Nezha extension.

Search with “Nezha” in the dialogue box to download it.

Coding:

In on start brick, set groups list = [0, 0, 0, 0, 0]

In forever brick, program to show different icons and pause for 2000ms, set the variable k as true and the variable I as 0.

In while brick, program to set variable NUM as a random number from 1~4 and save it as“I”in the group list, set i=i+1.

While button A being pressed, set variable j=1, set list num as the first value in the list and remove it. Then judge if the value of list num is equal to “j”, if yes, set to display A, or it display ×, and insert 0 in the beginning of the list, set variable k as false. Program with a similar way for button B、C、D.

Clear the screen and judge the length of the list is 0, if yes, set to display √ and pause for 2000ms, insert 0 in the beginning of the list and set variable k as false.

Complete Code:

Link:https://makecode.microbit.org/_P4Fbc9cFE8d7

Result

After powering on, it displays five characters at random first, press the buttons in accordance with the sequence to complete the game and LED displays √, if the button is pressed wrongly, it displays ×.

Leave a Reply

images
In March, ELECFREAKS supported 5 schools to carry out school science and technology festival activities
images
Children’s Programming Education is the Future Trend
images
Technical verification! Nezha series products can complete WRO competition tasks
images
Let's take part in the Ceremony of the New Factory of ELECFREAKS together!
images
Bluetooth Bee(HC-05 and HC-06) User Guide
images
In March, ELECFREAKS supported 5 schools to carry out school science and technology festival activities
Monthly Archive