Skip to content

Our First Lab: Making the Onboard LED Blink

Selecting the Blocks

We'll need a few simple blocks to blink the onboard LED. We'll want to turn on and off the LED using the following blocks:

  • Loops
    • repeat 10 times

repeat 10 times loop

  • Machine
    • In/Out Pins
      • set output pin

set output pin

  • Timing
    • delay 1 seconds

delay 1 second

Blocks on the Canvas

Once the blocks are selected and placed on the canvas, we'll have to change the second set output pin block so that it turns off the led (setting the pin to false). We'll also add a second delay block, so we have some time between turning off the led and turning it back on.

blinking the onboard led

We can execute our blocks by clicking on the angle in the circle next to the microcontroller

run button

blinking onboard led

Adding a variable

Next, we can add a variable block, so we can easily change the delay timing. We add a single variable and use it in both delay blocks.

  • Variables
    • Create variable...

create a variable

  • Click on Create variable... to create a variable and click ok

delay variable

  • Now the delay variable blocks are available for use on the canvas.

created delay

  • Drag the set delay block onto the canvas and place it above the loop block

move the delay variable

  • We'll need to set the delay to a number by using a Math number block

math number

  • Drag the number block to the delay block and set it to 0.5

set delay

  • Now we can get our delay block from the Variables area and insert it into our delay blocks on the canvas.

get delay variable change blink rate

Challenge

What is the fastest you can make the LED blink and still see it changing? What does this tell you about the human eye?