Skip to content
RoboLearn
Not completed

Block-based coding

ProgrammingBeginner25 minOpen the block editor ↓Before this: Algorithms and sequences

What you’ll learn

  • How block coding works
  • Events, sequences and commands in blocks
  • Where block coding is used for robots, and when to move to text

Blocks instead of typing

Block editors let you snap together code pieces that look like puzzle blocks. Their shapes only fit where they make sense, so there are no syntax errors, and you can focus on logic.

Editor Used with
Microsoft MakeCode BBC micro:bit and many robot add-ons
LEGO SPIKE App / Education apps LEGO SPIKE and Computer Science & AI kits
mBlock Arduino and Makeblock robots
Scratch Games and stories; same ideas

Key ideas

  • Event blocks start code: “on start”, “forever”, “on button A pressed”.
  • Command blocks do things: “show icon”, “set motor speed”, “wait 1 second”.
  • Control blocks repeat or choose: “repeat 4 times”, “if … then … else”.
  • Value blocks (round or pointed) hold numbers, sensor readings and true/false.

Moving to text

Blocks and text code express exactly the same ideas. MakeCode can show your blocks as JavaScript or Python, which is a great bridge. When programs get long, text becomes quicker to write and read.

Finished this lesson?