Once the LED strip has been connected to the Arduino and the MakeBlock programming language has been installed, we are ready to write our first script to turn on an LED. The Scripts tab provides access to different categories of commands in much the same way as Scratch does. However, the MakeBlock programming environment provides access to a number of robotics extensions to Scratch. One of these extensions is an LED command.

Accessing the LED Command

To create a MakeBlock (mBot) program, drag the mBot Program block onto the Scripts workspace. Then drag the Set LED Strip command onto the Scripts workspace.

Creating an mBot Program

Drag the Set LED Strip block to a position beneath the mBot Program block. It should snap into place.

Combining the mBot Program Block with the Set LED Strip Block

The LEDs in the LED strip are numbered 1 through 30.  To turn on LED 15 and set its color to blue, enter the number “15” in the space shown in Figure 6. Then right-click the number following the word blue to access a drop-down menu, and set the value to 20. The intensity of the LED can be varied from 1 to 255, with 255 being the brightest setting.

Setting LED Number 16 to “blue” with a Power Level of 20

Now that the program has been written, the next step is to send it to the Arduino.  Right-click the mBot Program block and select Upload to Arduino from the drop-down menu that appears.

Sending the mBot Program to the Arduino

This step translates the MakeBlock commands into the native Arduino language. The MakeBlock commands are shown in the left-hand editing window and the parallel Arduino commands are shown in the right-hand window.

Sending the mBot Program to the Arduino

Click the Upload to Arduino button (as shown in Figure above) to send the program to the Arduino. A status window with the message Uploading will appear. When the upload is complete, the message Upload Finish will appear in the status window.

The Uploading Status Window

When the upload is complete, LED 15 on the LED strip should turn on. To turn off LED 15, add a second line to the program changing the power level back to 0.

Turning off LED 15 by Setting the Power Level to 0