Steun onze actie WeGoSTEM

Voor onze actie WeGoSTEM zoeken we nog vrijwilligers. Doe mee via WeGoSTEM.be/meedoen

Programming robots in the classroom: an introduction

Children and young people enjoy programming physical devices like robots, but all too often it is considered too difficult and time consuming. In this Dwengo tutorial, we explain how they can receive a meaningful introduction to programming. Multiple challenges are offered and pupils are encouraged to discover multiple solutions.

This activity is suitable for children aged 10 to 15 years. The session takes 2-3 hours.


The unplugged way: 20 minutes

When you want a computer or a robot or another electronic device to perform a task, it needs to be programmed. Programming is giving meaningful, non-ambiguous instructions about what the robot needs to do. It may be tempting to use a computer. However, we believe it is preferable to let the students experience the importance of precise instructions. The first attempts may go wrong, but students quickly grasp how to formulate instructions in a non-ambiguous way. In a short group discussion afterwards you can ask the following questions: What is the link of this activity with programming?; What is a software bug?; Which drawing is harder to achieve and why? etc...

For this activity we prefer the CS Unplugged activity Marching order or Harold the robot or Programming your teacher to make a jam sandwich.

Graphical programming: 20-30 minutes

There are different languages used in programming. You may have heard about Java, Python, C, C++, Ruby, Pascal or Haskell, only to name a few. There are also graphical programming languages like Google Blockly, Scratch, Flow Code or ArduBlock. An introduction to graphical programming is preferable for students who take their first steps into programming. The 10 Google Blockly mazes is suitable fort his group. The activity is performed individually or in pairs, and followed by a short reflection about functions, loops and decisions.

Programming a light eating or line following robot: 120 minutes

Challenge 1: follow a square trajectory (40 minutes)

Wheeled robots can be programmed so that they drive in a straight line. The students are then encouraged to change the code to make the robot drive in the shape of a square. This immediately highlights a number interesting aspects of programming. For example, some students will program the robot to turn, then drive in a straight line, and copy-paste this code three times, while others will ask how they can program a loop. Students should be provide with the correct syntax and encouraged to consider whether their robot can be programmed more efficiently (or not). They will also discover that a robot is not perfect: None will have a robot that perfectly follows a square trajectory over and over again. Ask them how this problem could be solved, and explain the principle of feedback by using sensors.

Challenge 2: blinking leds (optional)

When the group has successfully completed Challenge 1, they can add a blinking LED. LED7 and LED13 on the Dwenguino board can be used to mark left or right. The blinking LEDs are implemented exactly like a driving car. Many students have difficulty breaking up a time fragment into several shorter fragments needed for the blinking mechanism.

Challenge 3: detecting light (20 minutes)

A wheeled will robot often fail to reach its target position if it is not provided with a feedback mechanism. This obstacle can be overcome by marking the target position with a light source, provided of course that the robot has light sensors and it is programmed accordingly. How to connect light sensors is explained in the Dwengo Light Sensor Tutorial. One sensor is added by way of example.

Challenge 4: a light eating robot (60 minutes)

In the previous challenge (3) students completed the code for their robot to find and drive in the direction of a light source. While this can be achieved with one sensor, the robot will perform this task more efficiently with two. The students can extend both the circuit and the code in order to have two sensors. Let the students design and test their own algorithm and only intervene when they have questions about syntax or when they get stuck. While it is vital that they are allowed to make and discover their mistakes, attention must be paid to managing their frustration level and discussing their code when needed.

Example framework

Please find an example framework that you can use in your classroom.

When you have more time

The activities and challenges above serve well as an introduction, but students learn most when they build a robot or physical device that answers a problem. The activity can be extended for more advanced students: ask them to define with their own problem and find a solution. For more inspiration, we offer the Dwengo projects and the Dwengo user defined projects.

Additional Materials