Skip to main content

Walkthrough: LED Toggle

This walkthrough is for you to get your first idea of how to use blokdots. We’ll only build a very minimal prototype: we will connect a button and an LED to blokdots and make the LED toggle on and off when pressing the button.

The walkthrough will guide you through every step along the way, so that even if you’ve never built a hardware prototype you can follow along easily.

Prerequisites

This example assumes no prior knowledge of blokdots.

Necessary Components

For this example you are going to need these components in addition to your board:

All of the components are included in the Grove Beginner Kit.

Project File

This file contains the finished project – if you get stuck along the way, feel free to download it and take a look!

blokdots File
Download the example .blokdots file [4kB]

Step by Step

1. Starting blokdots

blokdots overview

Before we start, just a quick explanation: In blokdots, there are two sections of the interface:

  • the “Board View”, where you manage everything related to your board and the currently connected components. This section is on the left side of the window.
  • the “Project”, where you select which components are used in your project and configure the logic of your project.

Please keep that in mind when going through this tutorial.

2. Connecting the Board

blokdots overview

Open blokdots and plug in your board using the USB cable.

The first time you connect your board, a little green box should appear on top of the Live View, flashing your board with the necessary Firmata. You don’t need to worry too much about that, it’s just something that is necessary for blokdots to be able to use your board. After a while, the green box should disappear and a label saying “Ready” should appear. If that does not happen, simply unplug the board and plug it in again, eventually, it should flash.

If you are on macOS and are using a Seeeduino Lots, you might have to install an additional driver before the board is recognized by blokdots.

If you are on Windows and have just installed blokdots, you might have to restart your computer before the board is recognized by blokdots.

3. Connecting Components

blokdots overview

The Beginner Kit already has components plugged in by default. We are using the LED at D4 and the button at D6.

If you are using a Grove shield or have the components already broken out, you can also just connect them with the Grove connector cables, of course.

blokdots overview

Now we need to make sure that blokdots knows which components are connected to the board right now. Click “Connect A New Component” in the Board View to open the connection guide and select the component you want to connect from the list. The connection guide then shows you which slot the component might be connected to.

If you are unsure where to connect a specific component, you can use this to see which slots a component will work at if plugged into. But in our case we already connected the components, so we need to tell the Wizard which slot they are plugged into. Click the dropdown menu in the middle of the Wizard, underneath the slot name, and select D4 when setting up the LED and D6 when setting up the button.

After setting up the components, you can try if they work:

  • In the slot D6 in the LiveView, where we set up the button, you see a little grey bar. When you press the button down, the bar should become green and the number 1 should be shown on top.
  • In the slot D4 in the LiveView, where we set up the LED, you see a toggle switch. When you toggle it on, the LED on your board should light up.

4. Programming

blokdots overview

Now, after setting everything up in the Live View, let’s focus on the Project. In the Live View, we can control which components are actually connected, while in the Project we can add logic to them.

First, we need to tell blokdots which of the components currently connected to the board we will actually use in our project. Right now we only connected the two components that we will also use, so in the list on the left side of the window, click the “use” button for both components.

blokdots overview

We are ready to go and let the programming begin – No worries though, you won’t have to write any code! In the main area of the window (the big white space) is a button, which lets you add cards. For every instruction you want to add to a project you add one card. In blokdots there are two variants of cards, but for this project we will only need the “If … then …” version.

blokdots overview

Once you click the button it changes to an empty card. The card is blue because it is not fully set up yet – that means there is no working instruction given on the card. Once we filled it out, it will become white. And if there is an error in the card, it will turn red.

Step by step, you now can click through the different options and create your card. Try to build “If button is pressed 1 time, then LED should toggle”. If a card is done, it will move away and make space for the button again. You can add as many cards as you like!

blokdots overview

If you are happy with your project, do not forget to save. There is a little save button below the big “Run Project” button in the top left corner of the project window.

5. Running the Project

blokdots overview

Now just press the big “Run Project” button to actually put the logic into action. Only when the project is running will the logic from the cards get applied, so if you ever wonder why nothing is happening when you interact with the hardware, make sure to check if the project is currently running.

If you want to change your project, you have to restart it for the changes to take effect. So simply press “Stop”, make the changes you want, and then press “Start” again.

The only thing that is left is to test your prototype! Try pressing the button. Now the LED should turn on and off when you press it. Congratulation, you just created your first prototype!