📚 Teacher's Guide

Complete guide for teaching Raspberry Pi Hardware Programming to primary school students in Malaysia.

📋 Course Overview

This comprehensive Raspberry Pi Hardware Programming course is designed for primary school students (ages 7-12) in Malaysia. The course introduces Python programming, hardware control, computer vision, and robotics through interactive, hands-on lessons with real-world projects.

12

Total Lessons

3

Modules

~10

Hours Total

40+

Activities

Course Objectives

By the end of this course, students will be able to:

  • Understand Python programming basics (variables, conditionals, loops, functions)
  • Control hardware components (LEDs, sensors, motors, cameras) using Python
  • Apply computational thinking to solve real-world problems
  • Build a complete human-tracking table fan project using computer vision
  • Develop logical thinking, problem-solving, and debugging skills

Alignment with Malaysian Curriculum

This course supports the Malaysian KSSR curriculum, particularly:

  • Sains Komputer (Computer Science) - Python programming, algorithms, hardware control
  • Reka Bentuk dan Teknologi (Design and Technology) - Building projects, problem-solving, engineering design
  • Mathematics - Logic, patterns, coordinates, angles, distance measurement

🎓 Module 1: Beginner (Python Programming Basics)

This module introduces Python programming and basic hardware control using Raspberry Pi. Students learn fundamental programming concepts and apply them to control LEDs and create simple interactive projects.

Lesson 1.1: Your First Program

⏱️ 45 minutes
Learning Objectives:
  • Understand what programming is and why it's important
  • Learn about Raspberry Pi and GPIO (General Purpose Input/Output)
  • Write and run first Python program
  • Learn about variables and how to store data
Materials Needed:
  • Raspberry Pi (with monitor, keyboard, mouse)
  • 1 LED (any color)
  • 1 Resistor (220Ω)
  • Breadboard and jumper wires
Key Activities:
  • Hello World: Print first message in Python
  • Variable Practice: Store numbers and text in variables
  • Blink LED: Control LED using GPIO - first hardware project!

Lesson 1.2: Making Decisions

⏱️ 45 minutes
Learning Objectives:
  • Understand conditional statements (if, elif, else)
  • Learn comparison operators (==, !=, >, <, >=, <=)
  • Apply conditionals to make programs smart
Materials Needed:
  • Raspberry Pi
  • 3 LEDs (Red, Yellow, Green)
  • 3 Resistors (220Ω each)
  • Temperature sensor (optional: DS18B20 or DHT11)
  • Breadboard and jumper wires
Key Activities:
  • Age Checker: Write code to check movie age restrictions
  • Grade Calculator: Assign grades based on scores
  • Temperature Monitor: Use if-elif-else to control 3 LEDs (red=hot, yellow=normal, green=cold)

Lesson 1.3: Repeating Actions

⏱️ 45 minutes
Learning Objectives:
  • Understand loops (for and while)
  • Learn how to use range() function
  • Master break and continue for loop control
  • Apply loops to create LED patterns
Materials Needed:
  • Raspberry Pi
  • 1 LED (any color)
  • 1 Resistor (220Ω)
  • Breadboard and jumper wires
Key Activities:
  • Count to 10: Use for loop with range()
  • Countdown: Create countdown from 10 to 1
  • SOS Pattern: Use nested loops to create SOS blink pattern (3 short, 3 long, 3 short)
  • Heartbeat: Create 2 quick blinks, pause, repeat

Lesson 1.4: Functions and Organization

⏱️ 45 minutes
Learning Objectives:
  • Understand what functions are and why they're useful
  • Create functions with def keyword
  • Learn about parameters and return values
  • Organize code into reusable blocks
Materials Needed:
  • Raspberry Pi
  • 3 LEDs (different colors)
  • 3 Resistors (220Ω each)
  • Breadboard and jumper wires
Key Activities:
  • Simple Function: Create say_hello() function
  • Parameter Function: Create greet(name) function
  • Return Function: Create add_numbers(a, b) that returns result
  • Multi-Function Controller: Create turn_on_led(pin), turn_off_led(pin), blink_led(pin, times, delay)
💡 Teaching Tips for Module 1:
  • Start with "Hello World" - students love seeing their first output
  • Use physical LED feedback - makes abstract code concepts concrete
  • Emphasize indentation - Python requires it!
  • Encourage experimentation - "What happens if I change this number?"
  • Connect to real-world: traffic lights, thermostats, washing machines use conditionals

💻 Module 2: Intermediate (Hardware Integration)

This module introduces advanced hardware components including sensors, displays, motors, and cameras. Students learn to read data, display information, control motors, and perform basic computer vision tasks.

Lesson 2.1: Reading Sensors

⏱️ 45 minutes
Learning Objectives:
  • Understand digital vs analog sensors
  • Learn to read GPIO inputs
  • Use ultrasonic distance sensors
  • Read button inputs
Materials Needed:
  • Raspberry Pi
  • Ultrasonic sensor (HC-SR04)
  • 2 Push buttons
  • Breadboard and jumper wires
Key Activities:
  • Button Press: Detect button clicks with GPIO
  • Distance Measurement: Measure distance with ultrasonic sensor
  • Proximity Alert: Light LED when object is too close

Lesson 2.2: Displaying Information

⏱️ 45 minutes
Learning Objectives:
  • Understand I2C communication protocol
  • Connect OLED/LCD displays to Raspberry Pi
  • Display text and numbers on screen
  • Integrate with sensor data
Materials Needed:
  • Raspberry Pi
  • OLED display (0.96" I2C) or LCD display
  • Breadboard and jumper wires
Key Activities:
  • Display Setup: Connect and initialize I2C display
  • Hello Display: Show "Hello World" on OLED
  • Sensor Display: Show real-time sensor data on display
  • Multiple Lines: Display temperature, distance, and time together

Lesson 2.3: Controlling Motors

⏱️ 45 minutes
Learning Objectives:
  • Understand motor drivers (L298N)
  • Learn PWM (Pulse Width Modulation) for speed control
  • Control motor direction and speed
  • Build motorized platform
Materials Needed:
  • Raspberry Pi
  • DC motors (2)
  • Motor driver (L298N)
  • Battery pack (4 AA batteries)
  • Breadboard and jumper wires
Key Activities:
  • Motor Setup: Connect motors to driver and Raspberry Pi
  • Direction Control: Make motors spin forward and backward
  • Speed Control: Use PWM to vary motor speed
  • Motorized Movement: Drive motors in patterns (forward, turn, stop)

Lesson 2.4: Camera and Vision Basics

⏱️ 45 minutes
Learning Objectives:
  • Set up Raspberry Pi camera module
  • Learn OpenCV basics for image processing
  • Capture and save images
  • Perform basic image manipulations
Materials Needed:
  • Raspberry Pi
  • Camera Module (Pi Camera V2 or HQ)
  • Ribbon cable
Key Activities:
  • Camera Setup: Enable camera and test capture
  • Photo Capture: Take photos with Python code
  • Video Stream: Display live camera feed
  • Image Effects: Apply filters (grayscale, blur, edge detection)
💡 Teaching Tips for Module 2:
  • Always double-check wiring before powering on - prevent short circuits!
  • Start with simple sensor readings before adding logic
  • Use print() statements for debugging sensor values
  • When working with motors, keep them off table (they can move!)
  • Camera placement matters - consider lighting and angle for best results

🏆 Module 3: Advanced (Complete Projects)

This module brings everything together to build a complete human-tracking table fan project. Students learn computer vision, servo motor control, system integration, and project presentation skills.

Lesson 3.1: Human Detection

⏱️ 45 minutes
Learning Objectives:
  • Understand computer vision and Haar cascades
  • Detect human faces and bodies using OpenCV
  • Draw detection boxes on video feed
  • Trigger actions when humans are detected
Materials Needed:
  • Raspberry Pi with camera
  • Completed sensor and motor setup from Module 2
Key Activities:
  • Face Detection: Detect faces in camera feed
  • Body Detection: Detect full bodies
  • Visual Feedback: Draw boxes around detected humans
  • Detection Count: Count how many people are in frame

Lesson 3.2: Motor Control for Tracking

⏱️ 45 minutes
Learning Objectives:
  • Understand servo motors vs DC motors
  • Control servo position with PWM
  • Build pan-tilt mechanism
  • Implement tracking logic to follow detected humans
Materials Needed:
  • Raspberry Pi with camera
  • Servo motors (2: one for pan, one for tilt)
  • Pan-tilt bracket or mounting hardware
  • Screws and mounting materials
Key Activities:
  • Servo Control: Test servo movement left-right (pan) and up-down (tilt)
  • Mount Camera: Attach camera to pan-tilt mechanism
  • Tracking Logic: Calculate position of detected human and move camera to follow
  • Smooth Movement: Add gradual movement for better tracking

Lesson 3.3: Integrating Display and Controls

⏱️ 45 minutes
Learning Objectives:
  • Integrate all components into complete system
  • Display system status on OLED
  • Add user control buttons
  • Implement automatic/manual mode switching
Materials Needed:
  • Complete system: camera, pan-tilt, motors, sensors
  • OLED display
  • 2 Control buttons
Key Activities:
  • Status Display: Show "Tracking: ON/OFF", "Humans: N", "Camera: X,Y"
  • Mode Switch: Button to toggle automatic tracking vs manual control
  • Manual Control: Use buttons to manually move camera when in manual mode
  • Error Handling: Display warnings if camera disconnected or motors not responding

Lesson 3.4: Complete Project Assembly

⏱️ 45 minutes
Learning Objectives:
  • Assemble complete human-tracking table fan project
  • Test all functions and debug issues
  • Prepare project demonstration
  • Document and present final project
Materials Needed:
  • All components from previous lessons
  • Project enclosure/box (optional)
  • Table fan or small fan to attach to system
  • Cable management materials (ties, clips)
Key Activities:
  • Final Assembly: Mount all components securely
  • System Test: Test complete workflow: detection → tracking → fan control
  • Debugging: Fix any issues found during testing
  • Demonstration: Present project to class, explain how it works
  • Cleanup: Create proper wiring diagram and code documentation
💡 Teaching Tips for Module 3:
  • Break project into small, testable steps - don't try to do everything at once
  • Encourage iterative design - build a basic version, then improve it
  • Have students help each other - peer debugging is powerful
  • Celebrate small wins along the way (e.g., "Great, the camera is tracking!")
  • Document everything with photos and videos for final presentation
  • Emphasize that projects don't need to be perfect - learning is the goal!

📊 Assessment Guidelines

Formative Assessment

Each lesson includes built-in assessment through:

  • Hardware Project Observations - Observe student wiring, coding, and debugging skills
  • Code Reviews - Check code organization, comments, and problem-solving approach
  • Quizzes - 10 questions per lesson with instant feedback
  • System Integration - Assess ability to combine multiple components

Grading Rubric

Criteria Excellent (4) Good (3) Developing (2) Beginning (1)
Code Quality Well-organized, commented, reusable functions, no syntax errors Organized with some comments, minor errors easily fixed Basic organization, significant guidance needed Disorganized, requires constant assistance
Hardware Skills Correct wiring, proper component usage, safe practices Mostly correct wiring with minor fixes needed Frequent wiring errors, needs help with connections Struggles with basic wiring concepts
Problem Solving Independently debugs and finds creative solutions Solves problems with some trial and error Needs hints and guidance to solve problems Cannot solve without direct instruction
Quiz Performance 90-100% correct 70-89% correct 50-69% correct Below 50%
Project Completion All features working, creative enhancements added All required features working Most features working, some bugs Partial implementation of project

Portfolio Assessment

Students should compile their work throughout the course:

  • Python code files from each lesson
  • Wiring diagrams and photos of hardware setups
  • Videos demonstrating working projects (LED patterns, sensor readings, etc.)
  • Final human-tracking fan project documentation
  • Self-reflection on learning journey and challenges overcome
  • Completion certificate

📚 Additional Resources

Recommended Extensions

  • Python Documentation (python.org) - Official Python documentation and tutorials
  • Raspberry Pi GPIO Documentation - Official GPIO programming guide
  • OpenCV Tutorials (opencv.org) - Learn advanced computer vision
  • Real Python (realpython.com) - Python tutorials and best practices

Required Hardware Kits

  • Raspberry Pi: Model 3B+ or 4 recommended (includes WiFi/Bluetooth)
  • Camera Module: Raspberry Pi Camera V2 or HQ Camera
  • Ultrasonic Sensor: HC-SR04 distance sensor
  • Display: 0.96" I2C OLED display (SSD1306)
  • Motor Kit: 2x DC motors with L298N motor driver
  • Servo Motors: 2x SG90 micro servo motors for pan-tilt
  • LED Kit: Assorted LEDs (red, green, yellow, blue)
  • Basic Components: Resistors (220Ω), buttons, breadboard, jumper wires

Safety Guidelines

  • Always disconnect power before changing wiring connections
  • Check polarity - LEDs and motors have positive/negative terminals
  • Use resistors with LEDs to prevent burning them out
  • Keep battery packs secure - loose batteries can short circuit
  • Avoid touching camera lens - fingerprints affect image quality
  • Supervise motor use - keep fingers and hair away from moving parts

Technical Requirements

  • Raspberry Pi: Model 3B+ or newer with camera module enabled
  • Power Supply: 5V/3A power supply for stable operation
  • Storage: Micro SD card (16GB+ recommended) with Raspberry Pi OS
  • Monitor, Keyboard, Mouse: For initial setup and development
  • Network Connection: WiFi or Ethernet for downloading libraries
  • Python Libraries: RPi.GPIO, OpenCV, Adafruit_GPIO, Adafruit_SSD1306