Skip to content
Live

How to code a robot: from drag and drop blocks to Python and C++

Most kids learn to code a robot in three steps: drag and drop blocks, then Python, then Arduino C++. This guide explains each step, a first program to try, and which robots and kits teach which language, with prices checked in October 2026.

Researched by Riley Hart · updated Oct 18, 2026 · How we research

Short answer

Start with block coding, where you snap commands together like puzzle pieces. Scratch is free and made for ages 8 to 16, and many robots use the same style. Next, move to Python on the same robot. Makeblock's mBot2, the BBC micro:bit and Petoi's Bittle X all let you switch from blocks to text. Arduino C++ comes last, for kids around 12+ and adults who want full control.

Robot or toolBlocksPythonC++ (Arduino)Price (Oct 2026)
Wonder Workshop DashYes (Blockly, Wonder apps)NoNo$189.99
VEXcode VR (virtual robot)Yes, free tierPaid tiersNoFree tier
Makeblock mBot2Yes (mBlock)Yes (mBlock)Yes (Arduino IDE)$149.99 list
BBC micro:bitYes (MakeCode)Yes (Python editor)No$17.95 board
ACEBOTT QD022 robot armYes (ACECode)YesYes$69.98
Petoi Bittle XYes (Petoi Coding Blocks)Yes (Python API)Yessee Petoi store
SparkFun Inventor's KitNoNoYes$99.95
Raspberry Pi robotsSome kitsYes (gpiozero)Optionalboard from $90

From maker and retailer pages checked October 18, 2026. Prices change.

Robots in this guide

Companions · Makeblock mBot2 Best for kids 10 and up moving from blocks to Python $150 Check price →Full profile
Companions · Wonder Workshop Dash Best for young kids learning to code $190 Check price →Full profile

What coding a robot really means

A robot program is a list of instructions plus rules. Instructions say what to do: drive forward, turn, beep. Rules say when: if the sensor sees a wall, stop.

Every robot language, from blocks to C++, uses the same three ideas. Sequences run in order. Loops repeat. Conditions (if and else) make choices. Learn them once and they carry over.

Step 1: block coding (ages 6 to 11)

Block coding lets kids drag commands into place, so there are no typos. Scratch, from the MIT Media Lab, is free and designed for ages 8 to 16. Many robot apps copy its style.

Wonder Workshop's Dash is a ready to use robot for grades 1+, $189.99 at Stemfinity. It is coded with two free apps, Blockly and Wonder, on iOS, Android and Chrome browsers, per Stemfinity.

No robot yet? VEXcode VR runs virtual robots in a browser. Its free tier includes block coding and 15 playgrounds, and VEX lists it for grades 3+.

Step 2: blocks on real hardware, then Python

The best second robot lets a child switch from blocks to text without buying anything new.

Makeblock's mBot2 is listed in its Age 6+ category at $149.99 (on sale for $94.99 when we checked). Makeblock says kids start with Scratch like blocks in mBlock and move to Python in the same app. Its CyberPi board also supports the Arduino IDE.

The BBC micro:bit is $17.95 at Adafruit. MakeCode codes it with Blocks or JavaScript, and the Micro:bit Educational Foundation runs a separate Python editor in the browser.

Petoi's Bittle X robot dog uses Petoi Coding Blocks, a Python API and C++ in the Arduino IDE, per Petoi. The ACEBOTT QD022 robot arm ($69.98, ages 12+) uses block based ACECode plus Arduino and Python, per ACEBOTT.

Step 3: Python on a Raspberry Pi

Python reads almost like English, which makes it the most common first text language. On a Raspberry Pi robot, the free gpiozero library turns motor control into short commands like robot.forward() and robot.stop(), per the gpiozero recipes.

Python is also how most AI robot projects are written, so it is worth learning before adding a camera or a talking AI model.

Step 4: C++ with Arduino

Arduino programs, called sketches, are written in C++. Every sketch has two parts, per Arduino's docs. setup() runs once when the board starts. loop() repeats over and over so the robot can respond to sensors.

C++ is stricter than Python, and a missing semicolon stops the upload. It also runs fast on cheap boards, which is why most robot car kits use it. The SparkFun Inventor's Kit v4.1.2 ($99.95, ages 10+) teaches Arduino coding through its projects and ends with a robot, per SparkFun.

Your first robot program, in any language

This same program works on almost any wheeled robot with a distance sensor. Build it in blocks first, then rewrite it in text.

  • Make the robot drive forward for two seconds, then stop.
  • Add a loop so it drives a square: forward, turn right, four times.
  • Read the distance sensor and show the number on screen.
  • Add a condition: if the distance is under 20 cm, stop.
  • Change stop to back up and turn, so the robot keeps exploring.
  • Change one number at a time, such as speed or turn time, and watch what happens.

Which language should your child start with?

  • Ages 6 to 8: blocks on a ready robot like Dash, or the free VEXcode VR.
  • Ages 8 to 11: Scratch at home, plus a robot like mBot2 or a micro:bit.
  • Ages 11 to 13: Python on the same robot, or block coding on a build kit like the ACEBOTT arm.
  • Ages 12+: Arduino C++ with a kit like the SparkFun Inventor's Kit, or Python on a Raspberry Pi.
  • Adults: skip blocks and start with Python or Arduino.

Questions people ask

What programming language do robots use?

Beginner robots use block coding, Python or C++. Arduino boards use C++, Raspberry Pi robots mostly use Python, and kids' robots usually start with blocks.

What is the best way for a kid to learn to code a robot?

Start with blocks on a robot that also supports Python, such as Makeblock's mBot2 or a micro:bit. Then the switch to text needs no new hardware.

Can I learn to code a robot for free?

Yes. Scratch and the free tier of VEXcode VR cost nothing. Arduino's Cloud Editor is free in a browser.

Is Python or C++ better for robots?

Python is easier to learn and used for AI and Raspberry Pi robots. C++ runs on cheap Arduino boards and gives more control. Most people learn Python first.

How long does it take to learn to code a robot?

A first program that drives and stops can take an afternoon with blocks. Moving to Python or C++ takes most beginners weeks of short sessions.

10+SparkFun Inventor's Kit v4.116 projects on a breadboard, no soldering, ending in a small robot.about $100Check price
10+Petoi Bittle XWalks, sits and does tricks. Takes 40 to 90 minutes to build.$319 to $469Check price
8 to 12ACEBOTT QD022 4 DOF Robot ArmGrab and stack small objects from an app.about $70Check price
Learn as you build · Builder Club

Your kid learns how robots really work

Builder Club turns a kit into real learning: one step at a time, with progress you both can see.

  • Step by step build screens with a check after every step
  • Photo help the moment you get stuck
  • Progress, levels and badges for each kid
  • A new project every month for the same kit
  • Works for parents who have never built anything
Black Friday is Nov 27Get the Black Friday prices on robot kits the day they drop

We check prices every morning and compare them with each model's 2026 low. One email when real deals land, plus our 5 minute Friday roundup. Unsubscribe anytime.