Link to main project page


This is a Python coding project using the RPi, LEDS and an Ultrasonic sensor. Depending on the duration of your lesson this project should take 1-3 lessons (1 hour per lesson).

This works well in pairs or small groups depending on the number of students and the equipment that you have available.

Kit List:

Ultrasonic sensor (HC-SR04)
LEDs (3: Red, green, orange)
Jumper cables male to Female solderless
Resistors 1K and 220ohm
GPIO expansion cable optional
Solderless 400 Point Breadboard


Ultrasonic Sensor

Main – Wire Up / Code It

This activity should take between 30-60mins depending size class, experience and dexterity. This can be spilt into 2 lesson one focusing on the circuit / build and the other focusing on the code. Take your time.

Hand out worksheet and ask the students (in pairs) to work out how to wire up the RPi to the breadboard. Use multiple colours if you have them. Use the Black for Ground, Red for Power and Blue or Green for the GPIO pins. Be consistent with your choice of colours.   Check out Jumper (hook-up)cables for more information

There are two ways that work well with this activity. One is build then code and the other is building in small sections and coding that section then moving on to the next bit.

Option 1.

Option 2

Decide which option you are going to use and state (display on the board) this to the class or let the students decide depending on their age/ ability and class size.

Hand out the kit for each group/ pair or individual. (RPI, Breadboard, Ultrasonic sensor, jumper cables, LEDs and resistors). Give the students plenty of time wire this up.  It can be very ‘fiddly’ with the small components and this can lead to some students feeling a little frustrated. If this is the case then give them another set of cables/ breadboard/ resistors to practice on while the ‘group’ finish the circuit. If there are no spare kits/ resources then get some students to be journalist and document the whole process with pictures video and interviews. During this time some students can be working on the code while others are building the circuit.


What is the code doing?
All the code contain variables, loops and boolean values. This a really clear way of explaining boolean in a simple physical way. By using code and LEDs and not just your classroom light switch the students get to create and make something that they are controlling through the use of code. This project could be enhanced further by having sound effects that are triggered when the LEds are on. A possible fun way to make their own music / musical instruments

Wrap Up

Show case each ‘groups’ work and ask each one what was the most challenging / interesting thing about this project.

Ask the students what could this new device be used for and what enhancements/ changes could the make to make it ‘better’ for them?


Give the student a copy of the Standards/ Programme of Study / State Level Content Standards. 1) The students, in their groups, should select (tick or colour- in) all the points that they feel the project covers. 2) Get the students to mark themselves as a group on wether or not the partially or fully achieved each point. 3) Mark themselves individually. This type of activity is really useful in getting the students to understand how you as an educator have evidence their learning and progression.

Using the pseudo code/ animations you will be able to see what the students actually understand about the project and relate this back to the assessment criteria/ standards.

Online mini quiz 4 questions These simple questions are good for exit tickets (leaving the classroom) or during the activity if you want to keep students at the same pace during the particular section of the project.

Below will find the curricular mapping for UK, USA and AUS/NZ

Curriculum Mapping:
UK Keystage 3 / 4
understand several key algorithms that reflect computational thinking, such as ones for sorting and searching; use logical reasoning to compare the utility of alternative algorithms for the same problem

use two or more programming languages, at least one of which is textual, to solve a variety of computational problems; make appropriate use of data structures such as lists, tables or arrays; design and develop modular programs that use procedures or functions

understand simple Boolean logic [such as AND, OR and NOT] and some of its uses in circuits and programming; understand how numbers can be represented in binary, and be able to carry out simple operations on binary numbers [for example, binary addition, and conversation between binary and decimal

undertake creative projects that involve selecting, using, and combining multiple applications, preferably across a range of devices, to achieve challenging goals, including collecting and analysing data and meeting the needs of known users.

develop their capability, creativity and knowledge in computer science, digital media and information technology.

develop and apply their analytic, problem-solving, design, and computational thinking skills.

Project mapped to commoncore


Digital Technologies knowledge and understanding
6.1 Investigate the main components of common digital systems, their basic functions and interactions and how such digital systems may connect together to form networks to transmit data
8.1 Investigate how data are transmitted and secured in wired, wireless and mobile networks, and how the specifications of hardware components impact on network activities
Digital Technologies processes and production skills
6.4 Define problems in terms of data and functional requirements, and identify features similar to previously solved problems
6.9 Manage the creation and communication of ideas and information including online collaborative projects, applying agreed ethical, social and technical protocols
8.10 Create and communicate interactive ideas and information collaboratively (online), taking into account social contexts
8.11 Plan and manage projects, including tasks, time and other resources required, considering safety and sustainability
Design and Technologies knowledge and understanding
6.2 Investigate how forces or electrical energy can control movement, sound or light in a designed product or system
8.3 Analyse how motion, force and energy, are used to manipulate and control electromechanical systems when designing simple, engineered solutions
Design and Technologies processes and production skills
6.8 Apply safe procedures when using a variety of materials, components, tools, equipment and techniques to make designed solutions
8.9 Effectively and safely use a broad range of materials, components, tools, equipment and techniques to make designed solutions
4.9 Plan a sequence of production steps when making designed solutions individually and collaboratively
6.10 Develop project plans that include consideration of resources when making designed solutions individually and collaboratively
8.11 Use project management processes individually and collaboratively to coordinate production of designed solutions