4.4 Emergency Vehicles
It is really important that emergency services, like ambulances and fire vehicles, can get to where they need to go as quickly as possible. There are multiple ways that emergency service vehicles can avoid getting stuck in traffic.
Loud sirens and bright flashing lights can draw attention to the fact that an emergency vehicle needs to get past, but it can also be helpful for emergency services to stop traffic automatically so they can safely cross intersections.
For this lesson, we will be working with another pair of students, using 2 micro:bits to alter the traffic light system we built in previous lesson. One micro:bit will fulfill the role of the ambulance, and the other micro:bit will operate the traffic lights.
In emergency situations, every second is crucial. It can potentially be the difference between life and death.
Emergency services help to keep our cities and towns safe and secure and commonly need to travel to distant locations as soon as possible. Each emergency service has multiple methods at their disposal for making their way through traffic congestion and potential disruptions.
One of the methods available to emergency services are the use of flashing lights. These lights are bright and alternate colours (generally between blue and red) to assist with catching our eye in a hurry. When we see these lights flashing, we know that we need to pull over to the side of the road as soon as possible to allow the emergency vehicle to pass, or pull up behind us to ask questions.
Emergency vehicles also have a siren at their disposal. These sirens are loud and high in pitch. This is so that the siren sound can echo across a long distance, and so that those close to the siren can also hear it and respond accordingly.
Some traffic lights are also installed with Emergency Vehicle Priority (EVP) which gives a green light to approaching emergency vehicles. Emergency services have an infrared strobe attached to their vehicle that alerts nearby traffic systems to their present situation (if they are driving fast and have their siren and lights turned on). This functionality is important, so that emergency services are able to get to their destination sooner.
Work with another pair of students so that you have access to 2 micro:bit kits in total.
Use 1 kit to build an ambulance which does the following:
- When you press the A button, emergency mode will activate.
- During emergency mode, the ambulance has 2 flashing lights: 1 red, 1 blue.
- During emergency mode, the ambulance broadcasts an Emergency signal using the micro:bit radio.
- When you press the B button, emergency mode will deactivate.
- When emergency mode is deactivated, broadcast an Emergency Over signal using the micro:bit radio.
Use the other kit to add an emergency mode to a traffic light:
Reuse your code from Lesson 4.3, Challenge 1:
- Use three RGB LEDs to represent the red, yellow and green lights of a traffic light.
- Create a 15 second timer that cycles through each light.
- Show the red light for 6 seconds, the green light for 6 seconds and the yellow light 3 seconds.
For this challenge, you will add:
- When an Emergency signal is received from the ambulance, activate emergency mode on the traffic lights.
- During emergency mode, the middle traffic light blinks yellow. The top and bottom traffic lights remain off.
- When an Emergency Over signal is received by the traffic light, resume normal operation.
- 2 micro:bit
- 2 sensor:bit
- 5 RGB LEDs
- on start
- pause (ms)
- running time (ms)
- radio set group
- radio set transmit power
- radio send string
- on radio received string
- if true then else
- 0 = 0
- 0 > 0
- 0 < 0
- set [variable] to
- remainder of
- strip set colour red
- strip set pixel colour at
- strip show
- strip clear
- set strip to neopixel
- When you press the A button, emergency mode will activate.
- 1 cardboard box (white)
- 1 pair of scissors
- 1 sheet of cardboard or paper
- 1 circular object (to trace around)
- 1 pencil
- coloured pencils, markers or pens
- sticky tape or Blu-Tack
Our goal with this activity is to create an Ambulance vehicle to mount your micro:bit and two RGB LEDs.
- Take your white square box and prepare it with your scissors to roughly resemble the shape of an ambulance. If you are including ‘wheels’ or any other additional parts, trace those parts (using the circular object) and cut those out of your extra sheet of cardboard / paper too.
- Using your coloured pencils, markers or pens, decorate your box to look like an ambulance. Once your ambulance has been decorated, stick the micro:bit, sensor:bit and RGB LEDs to the ambulance using sticky tape or Blu-Tack.
- Make sure that the RGB LEDs are connected to the micro:bit correctly. If so, plug in the micro:bit to a power-source (either a laptop or battery pack) and take your ambulance for a test drive.
If you have managed to get your ambulance and traffic light system working as planned, now try swapping your ambulance with another group. Does the emergency mode on their ambulance work with your traffic light?
Observe the interaction between the other group's ambulance and your traffic light. Does everything still function as anticipated, or does something unexpected happen? If something unexpected happens, then it is time to troubleshoot and discuss what the issue might be, and attempt to fix the problem.
Troubleshooting is a vital part of programming and working with technology. It is important to check that your devices and code are working correctly, especially in situations that involve objects of importance to the community and situations that involve a risk of harm towards others.
As you try to get the other group's ambulance working with your traffic light, here are a few things to think about:
- Are you using the same string to trigger your emergency mode?
- Are there differences in spelling that might be causing problems?
- Are your devices in the same radio group?
Once you have figured out how to get another group's ambulance working correctly with your traffic light, see how far you can take this idea. Can you get every ambulance and every traffic light in the class all working together effectively?
It's likely that almost everyone will need to adjust their code slightly to get this working, but when you do, activating emergency mode on any ambulance in the room should set off emergency mode on all of the traffic lights.
In this lesson we've learned about how technology can assist emergency services, and added an emergency mode to our traffic light.
In the next lesson, we'll put together everything we've learned to design some Smart City solutions.