Pixel Chaser Game With Micro:bit and Neopixel

by rajaamri in Circuits > Electronics

968 Views, 3 Favorites, 0 Comments

Pixel Chaser Game With Micro:bit and Neopixel

IMG20221122091232.jpg
Pixel Chaser Game with microbit and Neopixel

A fun play game that is easy to code and all you need is a micro:bit board and Neopixel Ring 24 LEDs !!!

This is my second version of this game. The first one was made only with micro:bit board I used LEDs of micro:bit screen, I decided then to make a game addressable LEDs arranged in a circle like the Neopixel Ring 24 LEDs used in this game . The code is more simple that the first version and the result is more attractive with more colorful displays.

The goal of the game is to stop the cycling light when it reaches the indicated LED and in the meanwhile you have to avoid enemy LED . If successful, your score will increase and the difficulty level too. If unsuccessful, the light cycle will restart.

I used micro:bit buttons to direct the sprite and to catch the pixels.

Supplies

download (13).jpg
Captures.PNG
IMG20221122090250.jpg
DBMPje3nLyoUwoqXbtAjmsLP68o@250x188.jpg
Captureew.PNG
  • BBC micro:bit V2 board
  • Neopixel Ring - 24 x 5050 RGB LED
  • 3 basic breadboard jumper wire (male to female) 
  • Edge Connector Breakout Board for micro:bit

Connections

IMG_20221018_190357.jpg
IMG20221122091232.jpg

. NeoPixels are very easy to connect. Our game requires just three connections:

  • GND - ground
  • Positive supply 3V (in the case of the micro:bit)
  • Data Input - Input signal from a digital output of the micro:bit board

Add Neopixel Extension to the Blocks Editor

Captureextension.PNG
vapture.PNG
Captureex.PNG

Before you can use NeoPixels with the MakeCode for micro:bit Editor, you will need to add Adafruit's NeoPixel extension to your environment. Todo do this, click on the Extension option circled.

This will open the dialog below from which you should select the Neopixel extension. Once you have done this you will find an extra category of blocks called Neopixel appears below Math where you find all blocks you need to code your LEDs.

Let's Code

neo1.PNG
neo2.PNG
neo3.PNG

The goal of the game is to stop the cycling light using buttons A+B when it reaches the indicated LED (the green one). If successful, the difficulty level will increase by accelerating the speed of the cycling light. If unsuccessful, the light cycle will restart. User can move forward by pressing button A and can move backward by pressing button B.

To code this game, I used MakeCode for micro:bit, a block-based visual programming tool. It's really easy to use, just drag and drop your blocks to write your code and you can see the result instantly on the simulator.

You can find more details about the code in this link.