mBlock for Arduino Mega project (1) simple buildin blink LED

Youth Innovation Lab
3 min readJan 30, 2020

--

By far, the mBlock is the best Scratch derived open source block tool, which can support multiple hardwares, not only Makeblock products, such as mBot, Nova Pi, but also other common use hardware, such as Arduino UNO and Mega.

mBlock 5 is the latest version of mBlock, it is derived from Scratch 3, and has the latest support of latest hardwares, such as Halocode from Makeblock, it has plenty of tutorials to cover those hardware from Makeblock, but it seems that the tutorials and projects for Arduino UNO and Mega is very limited, I can only find a handful of the projects from youtube and other web sites.

Fortunately, it is not too hard to figure out how to build the project using Arduino UNO and Mega, since both UNO and Mega share lots of common features, I will use the more powerful Mega to demonstrate the projects.

We will start by a very simple project, use the build in LED at digital 13, and build a blink LED project.

Before we start our digital 13 build in LED blink project, we will try it at the Arduino IDE first, it is the typical proof of concept step, so we know how to create the right project with the right result.

void setup() {
pinMode(13, OUTPUT);
}

void loop() {
digitalWrite(13, HIGH);
delay(1000);
digitalWrite(13, LOW);
delay(1000);
}

This code is very straightforward, in setup(), initialize the digital pin as an output mode, then in loop(), turn the LED on (HIGH is the voltage level), wait for one second, turn the LED off by making the voltage LOW.

Remember to set the right board (Arduino Mega) and port (port 10 in my test case), then choose “upload” (under Sketch menu), you can start to observe the result, the blink LED on board.

Now, it is the time to turn this Arduino project into a mBlock project.

Step 1: start mBlock 5, under “Devices”, click “+”, and choose the right device (Arduino Mega for our project), click “OK”.

step 2: hook Arduino Mega (or UNO) board to one of your USB interface, choose “Upload mode” on, and click “connect” to connect the Mega board.

Hint: remember to choose the right port (for multiple ports)

step 3: from category, choose the right category, then start to drag and drop the blocks, build the project, and save it in your computer (I prefer to save it on local computer, you can choose to save it on cloud only, that is up to you).

Now, it is the time to test it, it may be the simplest project we can build using mBlock for Arduino Mega board, and no need any extra sensors, give it a try.

Please add your comments or suggestions, we will post more tutorials soon.

key word: “youth coding club”, “YCIC”, “youth innovation”

--

--

Youth Innovation Lab
Youth Innovation Lab

Written by Youth Innovation Lab

Youth Innovation Lab is community based STEM education institute, we promote STEM education to minority community, and focus on advanced technology education.

Responses (1)