Teach Remote lab lessons

Teach lesson

Visual programming with a real Arduino (1/4): first visual program

Students use Blockly with a real Arduino to turn an LED on, wait, and connect block order with observable board behavior.

  • Arduino Board (visual)
  • 50 min
  • Secondary (ages 14–15)
  • English
  • Embedded systems
Arduino Board (visual)
Arduino Board (visual)

Learning Outcomes

  • Create a visual program with one output and a wait.

  • Connect instruction order with observable behavior.

  • Record concrete evidence from a real remote board.

Student activity preview

Activity Content

Preview only. In a class session, students can fill in responses and submit their work to the teacher.

1

From written steps to blocks

8 min

An algorithm is an ordered list of steps. In a visual program, each
block is an instruction and blocks snap together like pieces. If you change
the order of the blocks, you change the behavior.

Two words you will use all course long:

- Output: something the board *does* towards the outside world. Today the
output is an LED (a light). The built-in LED is already on the board, marked
with the letter L, so you do not need to connect any wires.
- Evidence: a concrete fact or description of what actually happened (which
LED you watched, what pattern you saw). Saying "it works" is not enough.

Today your program will: switch the LED on → wait → switch the LED off → wait,
and that will repeat.

In the editor you will see two special areas:

- Arduino run first: runs once when the program starts. It is for setup; in
this lesson it can stay empty.
- Arduino loop forever: repeats again and again while the board is on. If you
want an action to keep happening, put it here.

Before opening the lab, write what you expect to see if the program switches an LED on for one second and then off for one second, over and over.

2

Create and test the blink

22 min

Open Arduino Board (visual). You will see a block editor like the one in the
image. Use blocks, not text code.

The Arduino lab's visual editor in English: on the left the block categories Logic, Loops, Math, Text, Variables, Functions, Input/Output, Time, and Comms; in the centre the Arduino run first and Arduino loop forever blocks; at the top the Verify / compile and Upload into device buttons.

This is the lab's real editor. On the left are the block categories. In the centre are two big blocks: Arduino run first (runs once at the start) and Arduino loop forever (repeats without stopping). At the top are the Verify / compile and Upload into device buttons.

  1. Open arduino-visual-board ("Arduino Board (visual)" access).

  2. Notice the two big blocks: Arduino run first and Arduino loop forever. You will put your blocks inside "Arduino loop forever" so the blink repeats.

  3. In the Input/Output category, drag set built-in LED and choose HIGH (on).

  4. In the Time category, drag wait 1000 milliseconds (1000 ms = 1 second).

  5. Add set built-in LED again, now LOW (off).

  6. Add wait 1000 milliseconds again.

  7. If the program already had an example block (such as print "Hello world"), you can remove it: today you only need the LED.

  8. Press Verify / compile. If an error appears, the editor points to it; fix it and try again.

  9. Press Upload into device to send the program to the real board.

  10. Watch the board's built-in LED in the lab view for at least three cycles.

Your blocks should look roughly like this:

Visual block diagram: inside Arduino loop forever there is set built-in LED to HIGH, wait 1000 milliseconds, set built-in LED to LOW, and wait 1000 milliseconds.

Reference diagram for the program. Put these blocks inside Arduino loop forever; Arduino run first can stay empty in this session.

Arduino run first:
   (empty in this session)

Arduino loop forever:
   [set built-in LED]  [HIGH]
   [wait]  1000  milliseconds
   [set built-in LED]  [LOW]
   [wait]  1000  milliseconds

Verify / compile checks that the program has no errors and translates it into
instructions the board understands. Upload into device loads it onto the real
board so it runs.

Fill the table after you upload the program and observe the board. Use only
one row for your first blink test; you do not need to complete the extra empty
rows. In that row write:

- Output used: built-in LED.
- Observed on time: for example about 1 s, shorter than expected, or
hard to measure.
- Observed off time: use the same kind of answer, but for the part when the
LED is off.
- Matched expectation?: yes, partly, or no.
- Problem or adjustment: write none if it worked, or what you would check
if it did not match.

Output used Observed on time Observed off time Matched expectation? Problem or adjustment

Describe concrete evidence that your program ran on the real board. Include which LED you watched and what pattern you saw (on/off and how often).

3

Change one thing

12 min

To debug (find and fix problems) the key habit is to change one thing at a
time and compare. Now change only one value: set both waits to a new value between
250 and 2000 milliseconds. Verify / compile, Upload into device, and
observe again.

Before testing, predict what will change and what will stay the same.

Compare the first version with the second. What changed? If nothing changed, what would you check first?

4

Exit ticket

8 min

Explain, in your own words, the connection between algorithm, block, wait, and evidence in this lesson.