BLINK

PIPER MAKE EDUCATOR RESOURCES SERIES

To do this project, you will need a Piper Make Starter Kit. Get yours here:

Learn to blink a light using your Raspberry Pi Pico.

To get started, head to Piper Make and hit this icon:

Time: 30 minutes

Age Range: 8+

Difficulty: Beginner

LEARNING OBJECTIVES

Students will:

 

  • Create quick basic commands for real world problems then link to coding concepts
  • Understand computational thinking concepts, including algorithms, sequence of instruction, and loops
  • Demonstrate how computer hardware and software work together as a system to accomplish tasks.
  • Review these key electronics and programming understandings:
    • wire and pin positions for specific inputs and outputs.  
    • electric flow is sensed by the computer hardware (the pin) and programmed to have an effect in software (pin code), and thus on the screen (actions occurring).
    • the computer is programmed (ie block code is written) to detect electricity going into the pin (the pin is on). The program also sends a high voltage to the pin (turn the pin on) when light is desired (a button is pressed).
  • Determine potential solutions to solve simple hardware and software problems using common troubleshooting strategies.
  • Make observations to provide evidence that energy can be transferred from place to place by light, and electric currents.

STANDARDS ALIGNMENT

CA Computer Science Standards

3-5.CS.2: Demonstrate how computer hardware and software work together as a system to accomplish tasks.

LANGUAGE OBJECTIVES

CCSS.ELA.L.W.3.8: Recall information from experiences or gather information from print and digital sources; take brief notes on sources and sort evidence into provided categories.

CCSS.ELA.L.W.3.10: Write routinely over extended time frames (time for research, reflection, and revision) and shorter time frames (a single sitting or a day or two) for a range of discipline-specific tasks, purposes, and audiences.

CA ELD.3.C.11: Supporting own opinions and evaluating others’ opinions in speaking and writing

CA ELD.3.C.12: Selecting and applying varied and precise vocabulary and language structures to effectively convey ideas

MICHIGAN INTEGRATED TECHNOLOGY COMPETENCIES (MITECS)

Standards Alignment

1B-CS-01: Describe how internal and external parts of computing devices function to form a system. Subconcept: Devices; Practice 7.2
1B-CS-02: Model how computer hardware and software work together as a system to accomplish tasks. Subconcept: Hardware & Software; Practice 4.4
1B-CS-03: Determine potential solutions to solve simple hardware and software problems using
common troubleshooting strategies. Subconcept: Troubleshooting; Practice 6.2
1B-AP-10 Create programs that include sequences, events, loops, and conditionals. Subconcept: Control; Practice 5.2
1B-AP-11 Decompose (break down) problems into smaller, manageable subproblems to facilitate the program development process. Subconcept: Modularity; Practice 3.2

Language Objectives

Michigan ELA, Grade 3-8, Research, 8: Recall information from experiences or gather information from print and digital sources; take brief notes on sources and sort evidence into provided categories.
Michigan ELA, Grade 3-8, Range of Writing, 10: Write routinely over extended time frames (time for research, reflection, and revision) and shorter time frames (a single sitting or a day or two) for a range of discipline-specific tasks, purposes, and audiences.

WIDA ELD Standards

ELD-SI.K-3.Argue:
● Ask questions about others’ opinions
● Support own opinions with reasons
● Clarify and elaborate ideas based on feedback
● Defend change in one’s own thinking
● Revise one’s own opinions based on new information

ELD-SC.2-3.Argue.Interpretive:
Interpret scientific arguments by
● Identifying potential evidence from data, models, and/or information from investigations of phenomena or design solutions
● Analyzing whether evidence is relevant or not
● Distinguishing between evidence and opinions

CONCEPTS

Students will need to remember the micro controlling electronics concept that each GPIO pin on the Raspberry Pi Pico has a number. They learn that they need to create PiperCode to control the GPIO pins on their breadboard and that will control what happens to their LED light output. They will write a repeat forever loop with code blocks inside to turn the light on, wait, then turn off, to blink the LED.

PARTS

Raspberry Pi Pico, breadboard, charging cable, M2M Black jumper wire, Blue LED, 330 Ω Resistor

GPIO SETUP

LED, GP25, GP15

OVERVIEW OF STEPS

Step 1: Raspberry Pi Pico

The Raspberry Pi Pico includes an RP2040 microcontroller, which is a type of integrated circuit (IC). Typical microcontrollers have a processor, memory and input/output (I/O) peripherals. The Pico’s RP2040, as well as connectors and other components, are mounted on a printed circuit board (PCB).

Take a look at your Pico—it’s the size of a stick of gum, but in the middle of its green PCB, you can see the square, black RP2040. On the sides are the GPIO pins.

Step 2: Get to know your GPIO pins

Your Pico “talks” to both your hardware (LEDs, sensors, etc.) and your computer. The USB cable lets the Pico talk to your computer, but how does your Pico communicate with the hardware?

In the Getting Started tutorial, you learned about the GPIO pins on the Pico and you used one of them as an input.

In this tutorial, we will use a GPIO as an output to power an LED.

Step 3: Onboard LED

Start by finding the onboard LED: it’s a small rectangular component on the top left of the board next to the microUSB port. There’s a small label that says ‘LED’.

LED stands for Light Emitting Diode. A Diode is a kind of electrical component that has two slightly different layers, and electricity will only go through them in one direction. All diodes emit, or give off, some kind of energy when electricity passes through them. Light emitting diodes give off a lot of energy in the form of visible light when electricity passes through them.

The GPIO pin connected to the LED is an OUTPUT which means when you turn GP25 ON, this light will switch on. But since it’s an onboard GPIO pin, no wiring is required.

Step 4: Plug in your Pico

Let's go ahead and plug in your Pico to your computer:

Click CONNECT to communicate with your Pico, then, click NEXT.

Step 5: Time to start coding

Awesome! So how do we make that onboard LED blink on and off? Let’s break it down.

From the Chip menu, drag out a Start block and place it in your workspace. Now, drag out a Turn Pin block from the Chip menu (for turning ON the LED), and connect it to the bottom of the Start block.

Once you've built the code above, click NEXT.

Step 6: More Chip blocks

Now let's build out the rest of our Chip menu blocks and attach them all together. From the Chip menu, drag a wait block out and attach it to the turn pin block. This will keep the LED ON for some time.

Now, drag another turn pin block out and attach it to the bottom of the wait block. This will turn OFF the LED.

Click NEXT.

Step 7: Variables

But how do we tell our Pico that the onboard LED is what we want to turn ON and OFF? And for how much time?

With our Chip blocks in place, let's update the variables.

In a computer program, variables are things that contain values that can be changed.

The variables in your program are the GPIO pin number, whether to turn that GPIO ON or OFF, and the wait time (in seconds).

To select the onboard LED, pick GP25 from the drop down menu on the turn pin blocks. Turn it ON in the first turn pin block, and OFF in the next.

How long do you want the LED to stay on? Well, go ahead and change the time in that wait block.

When you are done trying out different wait times, click NEXT.

Step 8: Loops

Now what if we want the LED to keep blinking repeatedly? Let’s use that handy loop function!

With the Chip blocks in place and the correct variables, let's put a Loops block in our program!

Disconnect the first turn tin block from the start block. From the Loops menu, drag a repeat forever block and connect it to the start block. Snap the two turn pin and wait blocks inside the repeat forever block, and change the wait variable in the repeat forever block to 1 second.

Click NEXT.

Step 9: Start your code!

The big moment has arrived. Let's see if your code works. Go ahead and click the START button in the upper left corner of your workspace.

Is your onboard LED blinking?

Go ahead and see what happens when you change the wait times. Make sure to hit START again if you modify the code.

When you are done experimenting with different wait times, click NEXT.

Troubleshooting:

  • The most common mistakes students make is to have the incorrect pin number in the code. Also make sure that they are first turning ON the pin, then turning it OFF.
  • The LED must be inserted properly into the breadboard to work.

Step 10: Let's build some more

That onboard LED didn’t require any wiring, right? But we’ve got a bunch of LEDs, how do we wire those?

Let’s grab the breadboard, jumper wires, an LED and a resistor!

Any color LED and any color jumper wire will work so customize away!

When you have your parts, click NEXT.

Step 11: Digital View

When building hardware and coding it, having the GPIO pin map handy can help us figure out where we’re plugging things in. We have this all ready for you in the Digital View tab in the bottom left of your workspace!

Let's leave the Digital View open while we work on the next steps.

Click NEXT.

Step 12: Build the LED and wires

So let’s go back to our circuit flow, how should the LED be positioned?

Power is sent from: the Pico's OUTPUT pin (when it's on) → through the resistor → to the anode (+) of the LED → through the body of the LED → to the cathode (-) of the LED → through the wire → to one of the Pico's GROUND pins.

Push the long lead (the anode) into a breadboard hole in the same row as the resistor end. Plug the short lead (the cathode) into a breadboard hole on the other side of the center gap. Remember the rows on either side of the gap have different horizontal connections so electricity will only flow through the LED!

Use a male-to-male (M2M) jumper wire to connect the row with the LED cathode to a ground pin on the Pico. Your finished circuit will look like this:

You can expand the image to get a better view by clicking the icon in the upper-right of the image!

When you finish building your circuit, click NEXT.

Step 13: LEDs

Which way do we plug in the LED?

Hold the LED in your fingers: you’ll see one of its leads is longer than the other. The long lead is known as the anode, and represents the positive (+) side of the circuit; the short lead is the cathode, and represents the negative (-) side.

At the bottom of the colored part of the LED, there is a thin ridge. The flat spot on the ridge also indicates which side is the cathode (-).

When you find the long lead of your LED, click NEXT.

Step 14: Build the resistor

We don’t want too much current flowing through the LED (it can damage its internal workings), so let’s control that current using a resistor! Let’s think about the circuit we’re setting up here.

POWER flows from a GPIO OUTPUT pin → through the resistor → through the LED → to the GROUND.

The resistor is attached between the OUTPUT pin and the LED. As long as the resistor is in the circuit's loop, it will protect the Pico and the LED.

Click NEXT.

Step 15: Change your variables

Great work! Now, let's take the code we wrote for the onboard LED and change it so it will work for this external LED.

We are using a different GPIO pin, GP15, so let's change both turn pin variables to 15.

Click the START button and see if your external LED blinks! If it doesn't work, don't fret! Troubleshooting is part of being an engineer.

Click NEXT.

Step 16: Explain It!

Click STOP. Change the wait times in the wait and repeat forever blocks. After you’ve changed the values, click START to run your code. How did the LED’s blinking change?

Try out values like 0.25, 0.5, 1.0, 2.0 and 20.

Click NEXT.

Step 17: Troubleshooting

In the DIGITAL VIEW, you should see the voltage of pin GP15 changing as the LED pulses. If you don't see any changes in the DIGITAL VIEW, check your code and make sure you are turning pin 15 ON.

If your light is NOT blinking but you see GP15's voltage changing in the DIGITAL VIEW, then your problem must be in your hardware.

Go back to the "Build the LED and wires" step and make sure you put the LED in correctly, aligning to the rows of GP15 and the resistor.

If you get your LED to blink, click NEXT.

Step 18: Self Check!

What are devices in the real world that require blinking lights?

Once you've found a few real-world examples, click NEXT.

Step 19: You Finished!

Click EXIT to return to the menu and start your next coding challenge.