top of page

[Project] A Raspberry Pi Linkbot Siren System as Police Car, Ambulance, or Fire Truck


Introduction:

Linkbot is a reconfigurable modular educational robot. Raspberry Pi is a low-cost single-board computer. Barobo Raspberry Pi is designed to run C-STEMbian, a free open source Linux operating system based on Raspbian for absolute beginners to use Raspberry Pi effectively. It provides a user-friendly solution for physical computing --- making and building in the physical world, and integrating sensors into Linkbot systems using Raspberry Pi.

In this project, a Linkbot and Raspberry Pi are used to build a police car, ambulance, or fire truck with a flashing light. The robot moves with a blinking RGB LED and siren of police car, ambulance, and fire truck. The entire system is controlled by a program including wiringPi with only 20 lines of code!

Information:

  • Grades: 7 – 12

  • Duration: 6-20 Hours

  • Level: Advanced (using Raspberry Pi)

Products Used in the Project:

Parts Used in the Project:

  • 1 Linkbot-I

  • 1 Ball Caster

  • 2 3.5” wheels

  • 2 Snap Connector

  • 1 Cube Connector

  • 1 Raspberry Pi 3 Model B with SD card

  • 1 USB Cable to connect Pi to Linkbot

  • 1 Mini breadboard

  • 1 RGB LED

  • 1 5V battery holder

  • 1 5V battery

  • 1 USB cable for 5V battery

  • Some jump wires from Arduino Uno Starter Kit

  • Some screws from Linkbot Pi Pack

Setup:

The Raspberry Pi Linkbot Siren System as a police car, ambulance, or fire truck with a flashing light is shown in Figure 1. The detailed wiring information can be found in section 11 “Adding Sensors to Linkbot Using Linkbot Pi Pack” of the textbook Learning Physical Computing with Raspberry Pi for the Absolute Beginner. The Complete PDF files is available to you if you purchase a Barobo Arduno Uno Starter Kit or Barobo Raspberry Pi Starter Ki.

Figure 1: A Raspberry Pi Linkbot Siren System as a police car, ambulance, or fire truck.

Programming the Raspberry Pi Linkbot Siren System in Ch:

A Ch program linkbotSirenPi.ch can be used to control this Linkbot Siren System. Details for each robot member function for CLinkbotI can be found in the textbook “Learning Robot Programming with Linkbot for the Absolute Beginner”. How to write a C function can be found in the textbook “Learning Computer Programming with Ch for the Absolute Beginner”. The entire PDF files for these two textbooks are available in C-STEM Studio. The detailed information about wiringPi functions can be found in textbook Learning Physical Computing with Raspberry Pi for the Absolute Beginner.

/* File: linkbotSirenPi.ch

Drive a robot and play a siren at the same time

while making an RGB LED blink */

#include <wiringPi.h>

#include <linkbot.h>

CLinkbotI robot;

double radius = 1.75;

double trackwidth = 3.69;

//Set up wiringPi

wiringPiSetupGpio();

//Set up pin 4 for output

int ledPin = 4;

pinMode(ledPin, OUTPUT);

digitalWrite(ledPin, HIGH);

//Play police car siren while the robot drives forward

robot.driveDistanceNB(45, radius);

robot.playMelody(PoliceCarSiren, 1);

//wait for driveDistanceNB() to finish

robot.moveWait();

robot.turnRight(180, radius, trackwidth);

//Play an ambulance siren while the robot drives backward

robot.driveDistanceNB(45, radius);

robot.playMelody(AmbulanceSiren, 1);

robot.moveWait();

robot.turnRight(180, radius, trackwidth);

//Play a fire truck siren while the robot drives forward

robot.driveDistanceNB(45, radius);

robot.playMelody(FireTruckSiren, 1);

robot.moveWait();

bottom of page