Make every birthday celebration super, duper awesome with this Birthday Candle Bot trick. Program your robot to sing a sweet Happy Birthday tune and you can even blow out it’s flickering LED candle eyes when it’s done!
First, you’ll need to get started with a few programs, tools, and materials! Here’s a list of the things you’ll need:
You’ll also need to download your trick and costume!
Download the Costume: birthday-candle-bot-costume.pdf.
Download the Code: birthday-candle-bot-code.zip.
This is an Arduino activity, so make sure you download the program and the library here.
Once you’re all setup, check out a sample snippet of your code below. It’s much longer, but here’s what you should see at the top:
#include <LittleRobotFriends.h>
int x;
unsigned long nextTime = 0;
boolean candleState = false;
LRFSong happyBirthday = {
.length = 19,
.octaveShift = 0,
.pattern = { LRFColor_Red, LRFColor_Red, LRFTransform_Random, LRFDuration_DoubleLong },
.sounds = {
{ LRFNote_C, LRFOctave_4, LRFIntonation_Flat, LRFDuration_Medium, LRFDuration_Short },
{ LRFNote_C, LRFOctave_4, LRFIntonation_Flat, LRFDuration_Medium, LRFDuration_Short },
{ LRFNote_D, LRFOctave_4, LRFIntonation_Flat, LRFDuration_DoubleMedium, LRFDuration_Short },
{ LRFNote_C, LRFOctave_4, LRFIntonation_Flat, LRFDuration_DoubleMedium, LRFDuration_Short },
{ LRFNote_F, LRFOctave_4, LRFIntonation_Flat, LRFDuration_DoubleMedium, LRFDuration_Short },
{ LRFNote_E, LRFOctave_4, LRFIntonation_Flat, LRFDuration_Long, LRFDuration_Medium },
The program tells your robot when its hair sensor is hugged (hug = long hold). When this event is triggered your robot enters candleState mode. This means your robot will start singing happy birthday followed by a hooray expression, then the eyes will flicker orange and yellow. Blow into the microphone to switch off the “candles”!
There are a few other important elements in the program. Check out the snippet of the setup code below:
void setup(void)
{
lrf.setup();
lrf.setBoredomTimer(0);
lrf.disableEventExpressions();
lrf.setEventHandler(LRFEvent_RobotIsSleeping, NULL);
lrf.setEventHandler(LRFEvent_Hug, &candleOn);
lrf.setEventHandler(LRFEvent_SoundTooLoud, &candleOff);
}
Your robot has default expressions already set on its firmware. `void setup()’ runs once, so you’ll need to turn off some default settings here. In this case, your robot’s boredom timer, default expressions, and sleep setting is disabled. There are two new event handlers called here to trigger the touch and sound sensor so your trick works.
It’s time to upload the Birthday Candle Bot trick onto your robot. You’ll need to connect your robot to the computer with the USB cable.
Make sure your board and port is connected, then simple click the upload button!
You’ll know when the trick is uploaded when your Arduino Sketch says “Done Uploading”.
Hug your robot’s hair sensor to trigger the Birthday Candle Bot trick! Best. Birthday. Ever.
Blow out the candle after the trick!
Print the costume out on regular paper, or cardstock paper if you want it to last longer. Whip out the pencil crayons, markers, and scissors. Secure the costume onto your robot with a bit of tape and you’re done!
Download your costume here!
Make sure you print your costume in Actual Size, otherwise it won’t fit!
If you want to take this activity one step further, try completing a few of these challenges!
Change the flickering eye colour of your Birthday Candle Bot. Adjust the pattern section of the code below!
LRFSong hooray = {
.length = 7,
.octaveShift = 0,
.pattern = { LRFColor_Orange, LRFColor_Yellow, LRFTransform_Flip, LRFDuration_DoubleLong },
Change the Event Handler to make your Birthday Candle Bot turn ON when you shake it! Here’s a hint - you’ll need to change the section of the code below.
void setup(void)
{
lrf.setup();
lrf.setBoredomTimer(0);
lrf.disableEventExpressions();
lrf.setEventHandler(LRFEvent_RobotIsSleeping, NULL);
lrf.setEventHandler(LRFEvent_Hug, &candleOn);
lrf.setEventHandler(LRFEvent_SoundTooLoud, &candleOff);
}
Make your robot sing the birthday girl or boy’s favourite song. You’ll need to find a music sheet with all the song notes, then change the song section of your code!
LRFSong happyBirthday = {
.length = 19,
.octaveShift = 0,
.pattern = { LRFColor_Red, LRFColor_Red, LRFTransform_Random, LRFDuration_DoubleLong },
.sounds = {
{ LRFNote_C, LRFOctave_4, LRFIntonation_Flat, LRFDuration_Medium, LRFDuration_Short },
{ LRFNote_C, LRFOctave_4, LRFIntonation_Flat, LRFDuration_Medium, LRFDuration_Short },
{ LRFNote_D, LRFOctave_4, LRFIntonation_Flat, LRFDuration_DoubleMedium, LRFDuration_Short },
{ LRFNote_C, LRFOctave_4, LRFIntonation_Flat, LRFDuration_DoubleMedium, LRFDuration_Short },
{ LRFNote_F, LRFOctave_4, LRFIntonation_Flat, LRFDuration_DoubleMedium, LRFDuration_Short },
{ LRFNote_E, LRFOctave_4, LRFIntonation_Flat, LRFDuration_Long, LRFDuration_Medium },