PIPER MAKE

EDUCATOR GUIDES


YOU ARE HERE

Gaming expedition

Mission 1 of 5

Gaming expedition: Mission 1 of 5

Lighthouse


Beginner

1 hour

Grades 3 - 8

MISSION OBJECTIVE

Learn how to use technology to control LEDs and sound. Students will build a game controller that they will use in this lesson.

Back on Earth, our scientists have noticed a ship heading towards their lighthouse! In this mission, you will build and code a Traffic Light-like series of LEDs that your button presses can control as a simple introduction to the buttons on the Printed Circuit Board Assembly.

View student interface at make.playpiper.com
MISSION CHARACTERS

Commander

Scientist
MISSION MATERIALS

Computer with USB port and Chrome or Edge browser
Piper Make Base Station or Starter Kit
Piper Make Game Controller

MISSION RESOURCES

Learning Goals

  1. Students learn about shift registers and how they read inputs.  
  2. Students will learn how a controller outputs information into the system, including latch, clock, and data.  
  3. Students will gain an understanding of bits and bytes.  
  4. Students reinforce learning about conditionals, like if-do statements, in programming. 

Career Connections

Software Quality Assurance Analyst: Salary $99,620/yr
Web and Digital Interface Designer: Salary $83,240/yr
Computer User Support Specialist: Salary $71,530/yr
Video Game Designer: Salary $83,240/yr

Hardware Diagram




Code Diagram




Tutorial Steps

Lighthouse

We can make the controller do some stuff, but we have to build it and then connect it first...
Okay, I think we can do that.
Great! Let's get going!
Follow the build instructions for your Game Controller!
Not sure what version you have? Take a look at the image below:

Hmm seems like we need to connect that controller PCBA to the Pico. Let's unplug our Pico while we build!
NOTE: The controller wires may not be the same color as the picture below. Be sure to match the pin labels to the GPIO shown.
Click NEXT.

Ooh I think this controller uses a shift register!
Shift registers read inputs all at the same time, and then shift them out and to the microcontroller:
Ooh, and then the LATCH pulse gets the Pico to read all of the pressed buttons as 1s and 0s, each called a bit. 8 bits is a byte!
Hmm and then that CLOCK pulse seems to send the bits to the Pico in order until the byte is done!
Your controller has 14 buttons, so there are two shift registers to capture all of them.

Click NEXT.

Now we just need some lights to signal the boat
Add Resistors and LEDs to your circuit like it shows:
Double-check all of your connections. Once you are sure that they are correct, go ahead and plug your Pico into your computer. Then, click NEXT.

The first thing our program needs to do is set up the controller. Use a start block and a setup controller block from the Sensing menu:
Next, our program needs to use a loop to keep checking for button presses. Grab a repeat forever block from the Loops menu and then set the wait time to 0.1 seconds:
Now we are ready to program our controller to light up one of the LEDs!

Use an if else block from Logic to listen for a button press, and if the Left (1) controller button was pressed, turn on the LED connected to pin GP15. Otherwise, turn it off:
Click NEXT.

There are LEDs connected to pins GP13, GP14, and GP15. Let's use the Up (2) and Right (3) controller buttons to control them. We can do this by adding two more if else blocks:
Give it a try!

Click CONNECT, select your Pico, and then click START. Try pressing the buttons on the left side of your controller to control the 3 LEDs on your Breadboard!

When you are done testing it out, click STOP, then click NEXT.

Now that we are able to control the LEDs using the controller, let's use the other buttons on the Controller to play different notes!

Click the Variables menu and then click Create variable...
Name your new variable "pitch value". Then using blocks from the Variable and Values menus, set the initial value of the pitch value variable to 0 (zero):
The next step is to add an If block to detect if other buttons on the Controller were pressed. If they are, then set the pitch value variable to a note value:
Click the blue gear icon on the if block, and add 5 else if's - this will give the program a condition of each of the 6 buttons on the right side of the controller. Then, fill those conditions with more button tests and note values:
Click NEXT.

Now that we are using button presses to change the pitch of the note - let's use one more if to make sure that a button was pressed. If no button was pressed, the value of the pitch value variable will still be 0 (zero). If it's not zero, then a button was pressed!

Then, all we have to do is play a sound using our pitch value for the pitch:
That's it! Give it a try by clicking START! When you are finished playing your new musical instrument, click STOP, then click NEXT.

What else can you make your controller do? Try adding more lights, and sounds. If you have a Robotics Kit, can you use your controller to move the Walker or Rover?
Click EXIT to return to the menu and start your next coding challenge.

Blueprint

OPEN IN BLUEPRINT VIEWER  DOWNLOAD

Have an different version? Look for more information on the Support Page.

Troubleshooting Tips


Our customer support specialists are on hand to ensure your implementation of Piper runs seamlessly.
View Support Docs or Contact Support
EXPANDED RESOURCES

Term Glossary


Console Personal computers built for gaming (e.g., PlayStation, Xbox, Nintendo Switch).

Modding Making "modifications" to how a game sounds, plays, looks, or functions, usually by users.

Graphic User Interface (GUI) A way to display information on the computer screen where the user can use a mouse or touchscreen to click various buttons. (CAT)

Playtesting Playing through new inventions or builds to find bugs, test their ease of use, and get new ideas to build on.

Virtual Reality (VR) Computer technology that makes someone feel like they are elsewhere. It requires a player to wear a headset and use input devices to play games.

View Full Glossary

Standards Alignment