What’s better than a readymade police flasher light? One that you made!
What’s in it for you
Gear up to make your onboarded LED lights dance in yellow, green, blue, pink, white and red. You’ll start with timing them for a second each and then create forever loop for one long sequence.
Tools of the trade
In this project, you’ll learn how to create a police flasher light for your robot one that swings from red to blue and back again, just like the real one. You’ll be able to create a continuous loop out of it, and stop it at command.
Hardware : GizmoBot
Software : mBlock version 3
At the end of the project
When you finish all the steps in this project, you’ll find yourself with an LED robot police light that flashes red and blue for as long as you program it to! You’ll have learnt how to
Control the LEDs using PWM pins
Change colors by switching intensity
Use forever loop from the control blocks
Sneak peeks at key steps
Curious to see what you will be doing during the project. Here’s a sneak peek :
Connect the two LEDs to the correct PWM pins in the Arduino Mega board in the specified order.
Turn on the red light by activating pin 3 in the right LED and pin 6 in the left
The right LED must be connected to PWM pins marked as 3, 4, and 5. The left LED must be connected to PWM pins marked as 6, 7, and 8.
Programming the LEDs
Now you know that each LED is attached to three pins and each pin is assigned a color. So the right LED has red in pin 3, green in pin 4, and blue in pin 5. Similarly, the left LED has red in pin 6, green in pin 7 and blue in pin 8.
To activate read, you only need to activate pin 3 in right LED and pin 6 in left LED. You get the drift.
From the Robots block, drag set PWM pin __ output as __ and assign pins 3 and 6 to glow at max intensity first and then, after a wait, assign pins 5 and 8 to glow max intensity.
Do you see the lights glow bright? First in red and then in blue but then it stopped. What happened?
Hints for programmers
You will realize that the program runs only once. How can you make it run continuously? Here’s a hint: use the forever loop.
See it in action
When you finish your project, your miniature LED police light will look something like this :
Stuck in a rut
If you’re stuck at any point in the program, don’t fret! Our project leaders will unstick you, tell you what you’re doing wrong and how to fix it.
Want to one-up this
If you want to level up and try something better, we’re all ears! Show us the final project and how you’ve done it we’d love to see.
Recent Comments
Anna Sthesia
June 28, 2019
It is a long established fact that a reader will be distracted by the readable content of a page when looking at its layout. The point of using Lorem Ipsum is that it has a more-or-less normal distribution of letters, as opposed to using 'Content here, content here', making it look like readable English.
It is a long established fact that a reader will be distracted by the readable content of a page when looking at its layout. The point of using Lorem Ipsum is that it has a more-or-less normal tion of letters, as opposed to using 'Content here
It is a long established fact that a reader will be distracted by the readable content of a page when looking at its layout. The point of using Lorem Ipsum is that it has a more-or-less normal distribution of letters, as opposed to using 'Content here, content here', making it look like readable English.
Recent Comments