Sign in:

Tutorial #3: Blinky


Let’s talk about time.

There are many ways to divide time. We have big chunks of time like a decade or year. There are also smaller chunks like a week or day.

We can divide days into smaller moments too. There are 24 hours in a day, and 60 minutes in each hour. Each minute can be divided into 60 seconds.

A second is a pretty small unit of time, but when it comes to programming a second isn’t small enough! Computers and robots are capable of acting very, very fast which means that sometimes we need smaller units of time.

When you program with Cubelets you will use a unit of time called a “millisecond.” A millisecond is 1/1000th of a second. Said another way, there are 1000 milliseconds in a single second.

Milliseconds are hard to imagine because they happen so fast. Every time you blink your eyes about 200 to 300 milliseconds pass!

In this tutorial we will look at how we can use time to change the way our Cubelets behave.


  1. Follow the on-screen instructions to complete your robot.
  2. Click the button to download the cubelets_tutorial_3.cubelet lesson file.
  3. Power on your robot. Click the connection icon and complete the Bluetooth pairing process.
  4. In this tutorial we are going to reprogram a flashlight so it blinks on for one second and off for one second. This means we will be using a new block called the “wait block.”
  5. wait 1000 milliseconds block

  6. The “wait block” tells the program to continue executing the previous command for a fixed amount of time.
  7. To begin, you’ll need to load the “cubelets_tutorial_3.cubelet” file. Click the load icon in the toolbar. Then follow the system dialogue to select the proper file.
  8. load icon

  9. When the tutorial file loads you should see a canvas with a few preplaced blocks. You’ll need to arrange these blocks to create a working program. So let’s get started.
  10. Start by setting the Flashlight to full brightness. Drag the “set actuator value to” block into your “forever do” block.
  11. Drag the “number field” block to the right end of the “set actuator value to” block.
  12. The number field block allows us to directly set a value in our program. Unlike weighted average which relies on other blocks. The number field allows us to override and set block values.
  13. Set your Flashlight to full brightness by entering the maximum Cubelet Block Value in the number field. (255)
  14. Nice work! You’ve just made a line of code tells our Flashlight to turn on at full brightness.
  15. Next, we need to tell our Flashlight how long it should stay on. For that we will need a timing block.
  16. Drag one of the “wait milliseconds” blocks below the line of code you just completed.
  17. You’ll notice that this block has a default value of 1000 milliseconds. This means our robot will perform the code above this command for 1 second, then move on to the next bit of code.
  18. Our challenge is to create a blinking Flashlight that turns on and off. So far you’ve created a program that will turn your Flashlight on for 1 second.
  19. Now you need to add some code blocks so your Flashlight turns off for one second. Add the two blocks needed to turn the Flashlight off.
  20. If you need help click here for a hint.

    HINT: You’ll need to use the “set actuator value to” block and the “number field” block. Instead of a big number like, 255 you’ll need to set the Flashlight to a small number so it turns off.

  21. Next, add a timing command that tells our robot to keep the light off for 1 second. If you need a hint, click here.

    HINT: In the Timing menu, drag the “wait milliseconds” block below the line of code you just completed. Make sure the the number field is set to 1000 milliseconds.

  22. Nice job! Let’s read our program from top to bottom to see if it is complete. Remember we are trying to create a program for a Flashlight that blinks on for one second and off for one second.
    • Because we’ve placed the blocks inside the “forever do” block the program will repeat itself as long as the robot is on.
    • The first line of code tells the Flashlight to turn on at full brightness
    • The second line of code tells the Flashlight to keep the brightness at full value for 1000 milliseconds.
    • The third line of code tells the Flashlight to set its brightness to zero.
    • The fourth line of code tells the Flashlight to keep its brightness at zero for 1000 milliseconds.
  23. Do these instructions sound like a Flashlight that will blink on for one second and off for one second?
  24. Let’s find out! Select your Flashlight Cubelet from the block map and click “Program Selected Cubelet.”
  25. After Cubelets Blockly has finished updating your Cubelet you should see a blinking Flashlight. When you’re ready to move to the next tutorial click here. You’ll be using the same robot as the current tutorial, so keep it assembled.
  26. If you’d like to focus on something else and wish to save your tutorial progress for later, select your Flashlight from the block map and click “Restore Default Program.”

Tutorial Summary:

You can directly control a variable in a Cubelet by setting numeric values instead of weighted averages. When you are programming, you’ll need to include timing blocks if you want your robot to perform an action for a specific amount of time.