Program Arduino Board with PictoBlox

Blink Arudino Pin13 LED
Description
In this lesson, you will learn how to use PictoBlox to program Arduino Uno and create a script to make the Pin 13 LED blink. You will also learn about the UI elements of PictoBlox, the two working modes, and how to interface Arduino Uno to PictoBlox.

Introduction

Most of you must be familiar with Arduino Uno and how to program it using the conventional syntax-based programming language. Well, you might even be familiar with how complicated it can be to remember a number of lines just to make an LED blink. Well, that’s where Scratch comes into the picture, it is a graphical programming language that lets you write the entire code by just dragging and dropping the block instead of writing them. But there’s a teeny tiny problem, it’s almost impossible to control hardware using Scratch. This is where PictoBlox comes to the rescue. It is a Scratch 3.0-based programming software.

In this tutorial, we will briefly look over the UI elements of Scratch, the two working modes, and finally, we will understand how to interface an Arduino Uno to PictoBlox, and perform a small activity to make the Uno’s Pin 13 LED blink.

You can download PictoBlox from here.

Let’s begin!

Installing PictoBlox

Choose the appropriate Operating System (Windows, macOS, Linux) and follow the steps:

Understanding the UI of PictoBlox

Just like the Scratch UI, PictoBlox has the following basic elements: https://thestempedia.com/product/pictoblox/download-pictoblox/

  1. Sprite
  2. Stage
  3. Block
  4. Script and the Scripting AreaPictoblox UI interface scratch

Sprite

The Sprite is a character or an object that performs actions according to the projects. Technically, a sprite is the face of your project. Here, in PictoBlox, Tobi the bear is your coding buddy.  You can change the sprite if you wish to.

Stage

The stage is the area where your sprite performs the action. The background is known as the backdrop that makes your Stage beautiful. You can add the backdrop from the library, paint yourself, upload an image from the computer, or can even leave it blank.

Block

Block is the major element of all. You need to drag and drop the blocks in the scripting area. This simplifies or eliminates your need to worry about syntax.

Script and the Scripting Area

The script is what you can call your program or code. A combination of different blocks systematically makes your script. The script is where you decide what will your script do. You need to write your script in the Scripting Area.

Mode

Well, this is like the new dish on the platter. Unlike Scratch, you can work in two modes in PictoBlox:

  1. Stage Mode: In this mode, you can write scripts for the sprites and boards like Arduino Uno, Nano, Mega, and evive to interact with sprites in real-time. In case, if you disconnect the board in PictoBlox, you cannot interact anymore.
  2. Upload Mode: This mode allows you to write scripts and upload it to the board that you have selected so that you can use the board even when it is not connected to your computer.

Interfacing Arduino Uno to PictoBlox

To run the scripts written in PictoBlox, you must first upload it to Uno. Follow the procedure given below to interface Uno with PictoBlox.

  1. Connect Uno to your computer and open PictoBlox. If not yet installed, please refer to the Getting Started with PictoBlox tutorial HERE.
  2. In PictoBlox, go to the toolbar and click on the Board menu. Select Arduino Uno.
    In doing so, the Arduino Uno, Actuators, Sensors, Display, and Dabble extensions will automatically appear in the Block palette. If not, add them from the extension library by clicking on the purple-colored Add Extension button in the bottom-left corner of the window.
  3. Next, click on the Connect menu and from the fly-out menu, select the Port to which evive is connected e.g. COMXX or ttyXX. Once you select the port, the icon beside the Connect tab will become connected.Port Connection

Activity: Make the Pin 13 LED Blink

  1. To control the LED connected to pin 13, we’re going to use the set digital pin () output block.set digital pin block
  2. We need two such blocks to make the LED blink. So, duplicate it by right-clicking on it.Duplicate
  3. Set the output in this block to LOW.set digital pin to low
  4. Now, to control the speed of blinking, we’re going to use the wait block. Go to the Control palette and drag and drop one below each set digital pin () output block. //Gifs
  5. Now let’s stack all the blocks together.

    Stack Together

  6. Observe that this script will run only once; in other words, the LED will turn ON, wait for a second, then turn OFF. Blink LED once
  7. To make the process continuous, we’ll use the forever block from the Control palette. It will run the script till the time you stop the script.forever block
  8. To start any script, a hat block is necessary. Therefore, drag and drop When Arduino Uno starts up block above the script.Drag the Arduino Starts Up hat Block
  9. Now, we need to upload it to the board. For that, switch to Upload mode by toggling this button. The Stage is replaced by an editor window with the equivalent C++ program for the script. To upload the code, click on the Upload Code button. Uploading
    Once the upload is complete, the LED will start blinking. Blink Arudino Pin13 LED
evive Notes Icon
You can try changing the wait time to make the LED blink at a different speed.

Conclusion

In this tutorial, you learned a brief about PictoBlox, a graphical programming platform based on Scratch 3.0 and wrote a script make pin 13 LED blink.

Table of Contents