top of page
IMG_20170503_173438.jpg

Post

Raspberry Pi projects for kids: How to make an electronic game with Raspberry Pi Pico


Electronic game with Raspberry Pi Pico.
Electronic game with Raspberry Pi Pico.




Welcome to Makersgeneration: the home for cool STEM projects for kids and adults.



The word gaming always sounds Fun. It enhances problem-solving skills, critical thinking, and strategic planning. Additionally, gaming can foster social connections and teamwork through multiplayer experiences, allowing individuals to collaborate and communicate effectively with others.


The only thing cooler than just playing games is playing a game you made yourselves!!! That is precisely what we will be doing today in this post.


We will be recreating a very popular arcade game known as (Cyclone game) ourselves using some components such as a Raspberry Pi Pico board, RGB ring light, a push button, and a buzzer. This is a very good Raspberry Pi project for kids.


(If you are new to the Raspberry Pi Pico, check out the link below - Raspberry Pi for dummies):





Cyclone game


The Cyclone game is basically an arcade classic game that involves LED light going around in a circle and also a static LED. A button is provided for the user. If the user presses the button exactly when the moving LED collides with the static LED, they score a point, and the game restarts with the static LED at a new randomly generated position.


Cyclone arcade game.
Cyclone arcade game.


Required components

  • Raspberry Pi Pico board

  • micro USB cable

  • WS2812 RGB ring light (Neopixel)

  • Breadboard

  • Jumper wires

  • Push button

  • Buzzer

  • Thonny IDE for writing microPython code.

Required components.
Required components.



Operation

  • When the system is connected to power (say to a computer via USB cable) the LED ring light turns on a random LED (yellow).

  • The other LEDs are then turned ON (red) and OFF in a rotatory pattern - one after the other.

  • Once the push button is pressed and the red running LED is at the exact same position as the target LED: the target LED changes color to Green meaning the player scores a point and a buzzer beeps - else, the red LED keeps running.

  • The speed of the running LED is also chosen at random by the system from the range specified in the code.



The circuit


Circuit connection layout for cyclone LED game.
Circuit connection layout for cyclone LED game.



Tip: All Red wires are connected to Power (VBUS) and all Black cables are connected to GND.

Raspberry Pi Pico

Other component's signal pins

GP17

RGB LED (IN) pin

GP16

Buzzer pin

GP15

Push button pin

Raspberry Pi Pico Pinout diagram.
Raspberry Pi Pico Pinout diagram.



Actual circuit.
Actual circuit.






Project code in MicroPython


# import needed libraries (all libraries are inbuilt with microPython)
from machine import Pin, PWM
import neopixel
import time
import random

# pin assingment and buzzer frequency assignment
button = Pin(15, Pin.IN, Pin.PULL_DOWN)
buzzer = PWM(Pin(16))
buzzer.freq(500)

# initialize neopixel object
# pin17 is pico pin LED IN is connected to.
# 16 is number of LED in your strip (replace with your LED number
np = neopixel.NeoPixel(machine.Pin(17), 16)

# use random library to randomly pick target LED number
target = random.randint(0, 15)

# use random library to randomly select LED rotating speed
speed = round(random.uniform(0.01, 0.03)2)

while True:
    # chasing LED
    for i in range(0, 15):
        np[1] = (255,0,0)          #turn LED red per round trip
        np[target] = (255,255,0)   #keep target LED yellow
        np.write()                 #command to activate above command
        time.sleep(speed)    #set trip speed to randomly selected value
        np[i] = (0,0,0)      #turn off LED after each trip
        
        
        # hitting target with button
        while button.value() == 1 and i == target:
            np[target] = (0,255,0)   #turn target LED to Green
            np.write()               #activate LED command
            buzzer.duty_u16(1000)    #turn on buzzer
            time.sleep(0.5)          #keep buzzer on for half second
            buzzer.duty_u16(0)       #turn off buzzer
            
            target = random.randint(0, 15)  #reset value for target LED



Run code


Follow the simple steps below to save and run your code:

Click "File" then "Save" - a new window should pop up
Click "File" then "Save" - a new window should pop up



Click "Raspberry Pi Pico" to save your code inside the microcontroller.
Click "Raspberry Pi Pico" to save your code inside the microcontroller.



Save your code as "main.py". This will make your code run automatically once the Pico is connected to a power source.



Finally, click on the "Play button" to run your code.
Finally, click on the "Play button" to run your code.


Demo video




If everything works well: You're in for a lot of FUN!!!!!!!



This is where we draw the curtain for today. We have a lot more on this platform for you:



Follow the information below for more Technology activities for kids:



Online summer camp and summer camps in Takoma Park Maryland



You and your children are looking for nice activities to have fun and learn new things and skills. Come join us starting in May and this summer for more online coding courses for kids such as:


  • Python coding for kids and teens

  • Coding for elementary school students

  • Make video games

  • Electronics

  • Digital modeling (Create cars, rockets, rings, etc) for 3D printing and much more with the following link: Online summer camp


And the STEM summer camp in Maryland for your kids is organized in Takoma Park Maryland nearby Washington DC to have fun and learn more about robotics, coding, droning, and more. Check the link right here:




Other cute things to make and hand-crafts for kids


If you are looking for more cool Arduino and kids' electronics project ideas to do with your kids, take a look at these other activities:



Newsletter, follow, subscribe, and like the social media



If you like online STEM activities, consider subscribing to the newsletter and social media for updates, and don't miss any STEM events. Don't forget to subscribe to the newsletter at the bottom of our website ''www.makersgeneration.net'' for more events, tutorials, and freebies.



Subscribe to the Facebook group if you have yet registered. Content and tutorials are shared daily: Create and build STEM projects for kids



We can be reached at: contact@makersgeneration.net if any questions.



See you on soon.

Comments


Categories

Recent Posts

Archive

Search By Tags

Follow Us

Comments

Share Your ThoughtsBe the first to write a comment.
bottom of page