Lesson 3

Programming intro

In this lesson we are going to dive into the exciting world of programming!

What is programming?

Programming is the process of writing the code of a computer program.

Code is a list of commands that a computer should execute.

When we program the Arduino, we will be writing a list of commands that it will perform.

Below are several examples of commands Arduino can execute:
– Open the gate
– Get data from sensors 
– Show text on LCD screen
And much more…

 

What is a programming language?

 

Programming language is the language of the code used to program computers.

There are many different programming languages. Each has its own set of rules and commands. But programming languages are similar to each other, and if you know one language, it should be easy to learn other languages.

We will be using a programming language called Scratch.
Scratch is a programming language developed primarily for children.

What makes Scratch unique is that you don’t need to write commands; instead, you can visually drag & drop them.

A visual code editor creates a simple, visually stimulating environment for young programmers to learn.

Screenshot of mBlock Arduino programming interface as example of Scratch programming language.

How to program Arduino

 

We will use special software that will allow us to create code for Arduino, called mBlock.


Now it’s time to prepare your computer and the included USB cable(don’t connect the cable yet, we will soon explain the process).

 

 

 

*It is recommended to ask an adult to help you follow the next steps
 

Step 1: Download the software

Follow this link to download the software:
https://mblock.makeblock.com/en-us/download

When the page loads, find “mBlock PC version”.

Then, click on the button with your computer’s operating system (Download for Windows or Download for Mac).
We will be showing the installation process on a Windows computer. However, the process is similar for Mac computers as well.

Once the download is complete, run the installation file.

When asked if you want to install the software, click Yes.

If you see the following notification as well, click Allow access

Wait for the installation process to finish (this will take several minutes).

You will be asked to install a driver that is required to program the Arduino.
Click  INSTALL.

That’s it!
Click Finish to complete the installation and open mBlock.

Welcome to mBlock!

Step 2: Remove existing devices

In the Devices tab, remove any existing devices by clicking on the blue X as shown in the video below (in our case, the device is called “CyberPi,” but you might have other devices in this tab. Remove anything that is there).

Step 3: Add Arduino Nano

Click on the +Add button and look for Arduino Nano. Then, add it by clicking the big blue + button.
Make sure to choose Arduino Nano and not a similar-looking device (ex. Arduino Micro).

Now you should see Arduino Nano in your devices tab:

Step 4: Connecting the USB cable

Place your track on the floor next to your computer desk or table. The cable included in your kit is long enough for most desks and tables. If using a laptop, make sure it is placed safely on the desk and is not in danger of falling.

Connect the computer to the Arduino using the USB cable, as shown in the video below:

Step 5: Connect Arduino

Now, we will tell the software to connect. Follow the video below:

Step 6: Save settings

We don’t want to repeat the same process we just did every time we open mBlock, so let’s save our work by choosing the “Save to computer” option from the menu:

That’s it! We finished all the preparation steps and it is time to finally start making our racing track smart. We will do it right away in our next lesson!