15 Light Sensor Sets Pixels

Set the LED Pixel Color with Light Sensor

/* Use the light sensor to control the color of the LED rainbow pixels */ #include "LEDStrip.h" //The LEDStrip.h library gives your code access to special functions exclusive to the LED Pixels LEDStrip pixels = LEDStrip(3, 13, 12); //Set up the pixels by defining how many pixels (3) and where the pixels connect to the microchip void setup() { pinMode(A2,INPUT); //light sensor } void loop() { int color = analogRead(A2); //create variable called color that is an integer (whole number) with a starting value equal to the reading the light sensor color = map(color,0,1023,0,299); //map the analogReadings (0-1023) to the color values the LED pixels can show (0-299) //Now the light reading of 0 = 0 on the color scale. light reading 1023 = 299 color. light reading 512 = 150 color. pixels.setPixel(pixels.ALL,color); //set all pixels to a color determined by the 'color' variable pixels.draw(); //send the setPixel data to Bumblebee } // (c) 2024 Let's Start Coding. License: www.letsstartcoding.com/bsdlicense
 

Walkthrough Video

Watch the video for a line-by-line explanation of how the example program works. Then you'll be ready to make some changes of your own!

LED Pixel Color Spectrum


Use this spectrum to estimate the color values you'll need for your 'setPixel' arguments to achieve your favorite color!


This graphic represents how some values from the light sensor will be 'mapped' onto the pixel colors.

 

Challenges

Can you complete the challenges? Change the code in your code editor above. Upload your code to see the effect when you're finished. Complete a challenge? Check it off the list!


TRANSFORMERS and HASBRO and all related trademarks and logos are trademarks of Hasbro, Inc. ©2024 Hasbro.

14 Tune Pixel Colors

Tune LED Pixel Colors

/* Use the turn knob to control the color of the LED pixels */ #include "LEDStrip.h" //The LEDStrip.h library gives your code access to special functions exclusive to the LED Pixels LEDStrip pixels = LEDStrip(3, 13, 12); //Set up the pixels void setup() { pinMode(A0,INPUT); //turn knob } void loop() { int color = analogRead(A0); //Create a variable color that is an integer (whole number) and uses the analogRead of A0 as its starting value color = map(color,0,1023,0,299); //Because analogRead has a range of 0-1024 and the color range is only 0-299, use 'map' //map matches up two ranges of values. Now, a 1023 analogReading equals color 299. A 0 reading equals 0. A 512 reading equals about 150 pixels.setPixel(pixels.ALL,color); //set all pixels to a color value equal to the variable pixels.draw(); //send the setPixel data to the wings } // (c) 2024 Let's Start Coding. License: www.letsstartcoding.com/bsdlicense
 

Walkthrough Video

Watch the video for a line-by-line explanation of how the example program works. Then you'll be ready to make some changes of your own!

LED Pixel Color Spectrum


Use this spectrum to estimate the color values you'll need for your 'setPixel' arguments to achieve your favorite color!



This graphic represents how some values from the light sensor will be 'mapped' onto the pixel colors.

 

Challenges

Can you complete the challenges? Change the code in your code editor above. Upload your code to see the effect when you're finished. Complete a challenge? Check it off the list!



TRANSFORMERS and HASBRO and all related trademarks and logos are trademarks of Hasbro, Inc. ©2024 Hasbro.

13 Fade APA Colors

Variable Pixel Color Spectrum

/* Fade through all the colors of the rainbow LED pixels with a variable */ #include "LEDStrip.h" //The LEDStrip.h library gives your code access to special functions exclusive to the LED pixels LEDStrip pixels = LEDStrip(4, 13, 12); //Set up the pixels by defining how many pixels (4) and where the pixels connect to the microchip int color = 0; //create a variable that will determine the color showing on the pixels void setup() {}//nothing needed in the setup! void loop() { pixels.setPixel(pixels.All, color); //use pixels.All in the place where the pixel number normally goes, then the color (0-300) pixels.draw(); //Send the setPixel values to the rainbow LEDs color++; //increase the variable by 1 delay(20); //Wait 20 milliseconds with the pixels lit up as each color if(color == 299){ //once the color value reaches the max that the pixels can show... color = 0; //reset the variable to 0 and start rising all over again. } } // (c) 2024 Let's Start Coding. License: www.letsstartcoding.com/bsdlicense
 

Walkthrough Video

Watch the video for a line-by-line explanation of how the example program works. Then you'll be ready to make some changes of your own!

LED Pixel Color Spectrum


Use this spectrum to estimate the color values you'll need for your 'setPixel' arguments to achieve your favorite color!


 

Challenges

Can you complete the challenges? Change the code in your code editor above. Upload your code to see the effect when you're finished. Complete a challenge? Check it off the list!



TRANSFORMERS and HASBRO and all related trademarks and logos are trademarks of Hasbro, Inc. ©2024 Hasbro.

12 Shadow Alarm

Shadow Alarm

/* Turn on or off an alarm by passing a shadow over the light sensor */ int shadowCount = 0; //Variable keeping track of the shadows that cross the light sensor void setup() { pinMode(A2,INPUT); //light sensor pinMode(A5,OUTPUT); //speaker Serial.begin(9600); //set up the serial monitor } void loop() { if(analogRead(A2)<4){ //if the light sensor reading is below 4... shadowCount++; //increase the value of the shadow count variable by 1 delay(500); //pause 500 milliseconds (half a second) } if(shadowCount == 1){ //if the shadow count variable equals 1... tone(A5,500); // start playing a tone of 500 hertz delay(100); //delay 100 milliseconds tone(A5,1000); //play a tone of 1000 hertz delay(100); //delay 100 milliseconds } else{ //otherwise, if the shadow count variable doesn't equal 1... noTone(A5); shadowCount = 0; //set the variable equal to 0. } Serial.println(analogRead(A2)); //show the value of the analogRead the light sensor } // (c) 2024 Let's Start Coding. License: www.letsstartcoding.com/bsdlicense
 

Walkthrough Video

Watch the video for a line-by-line explanation of how the example program works. Then you'll be ready to make some changes of your own!

 

Challenges

Can you complete the challenges? Change the code in your code editor above. Upload your code to see the effect when you're finished. Complete a challenge? Check it off the list!


 

TRANSFORMERS and HASBRO and all related trademarks and logos are trademarks of Hasbro, Inc. ©2024 Hasbro.

11 Display Light Sensor Readings

Report Light Sensor Readings

/* Use the serial monitor to 'print' the values that the light sensor reports */ void setup() { pinMode(A2,INPUT); //light sensor Serial.begin(9600); //set up the serial monitor } void loop() { Serial.println(analogRead(A2)); //show the value of the analogRead the light sensor the serial monitor } // (c) 2024 Let's Start Coding. License: www.letsstartcoding.com/bsdlicense
 

Walkthrough Video

Watch the video for a line-by-line explanation of how the example program works. Then you'll be ready to make some changes of your own!

 

Challenges

Can you complete the challenges? Change the code in your code editor above. Upload your code to see the effect when you're finished. Complete a challenge? Check it off the list!


TRANSFORMERS and HASBRO and all related trademarks and logos are trademarks of Hasbro, Inc. ©2024 Hasbro.

10 LED Brightness Twist

LED Brightness Twist

/* Use the turn knob to adjust the brightness of one of the multicolor LED colors*/ void setup() { pinMode(A0,INPUT); //turn knob pinMode(9,OUTPUT); //LED } void loop() { //analogWrite works on LED pins 9,10,and 11 on Bumblebee analogWrite(9,analogRead(A0)/4); //Use the reading from the knob divided by 4, for the LED brightness } // (c) 2024 Let's Start Coding. License: www.letsstartcoding.com/bsdlicense
 

Walkthrough Video

Watch the video for a line-by-line explanation of how the example program works. Then you'll be ready to make some changes of your own!

 

Challenges

Can you complete the challenges? Change the code in your code editor above. Upload your code to see the effect when you're finished. Complete a challenge? Check it off the list!


 
 

TRANSFORMERS and HASBRO and all related trademarks and logos are trademarks of Hasbro, Inc. ©2024 Hasbro.

09 Morse Code Variables

Morse Code Variables

/*Use variables for Morse Code messages. This will make it much easier to update the speed of messages Rules of Morse Code: - Dots are 1 'unit' - Dashes are 3 'units' (3 times as long as a dot) - Spaces between symbols within the same letter are 1 'unit' of no signal - Spaces between letters are 3 'units' of no signal - Spaces between words are 7 'units' of no signal */ //all the variables used in this program are 'integers', shortened to int, which means they are whole numbers. int dot = 200; //milliseconds that a dot will last int dash = dot*3; //milliseconds that a dash will last int symbolSpace = dot; // space between symbols are the same duration as a dot int letterSpace = symbolSpace*3; //space between letters are 3 times the duration of symbol spaces int wordSpace = symbolSpace*7; //space between words are 7 times the duration of symbol spaces int LED = 8; void setup(){ pinMode(LED,OUTPUT); //Set the LED as an 'OUTPUT' } void loop(){ //S digitalWrite(LED,HIGH); //Turn on LED delay(dot); //wait one 'dot' with LED on digitalWrite(LED,LOW); //Turn off LED delay(symbolSpace); //wait before the next symbol in a letter digitalWrite(LED,HIGH); //Turn on LED delay(dot); //wait one 'dot' with LED on digitalWrite(LED,LOW); //Turn off LED delay(symbolSpace); //wait before the next symbol in a letter digitalWrite(LED,HIGH); //Turn on LED delay(dot); //wait one 'dot' with LED on digitalWrite(LED,LOW); //Turn off LED delay(letterSpace); //wait before the next symbol in a letter //O digitalWrite(LED,HIGH); //Turn on LED delay(dash); //wait one 'dash' with LED on digitalWrite(LED,LOW); //Turn off LED delay(symbolSpace); //wait before the next symbol in a letter digitalWrite(LED,HIGH); //Turn on LED delay(dash); //wait one 'dash' with LED on digitalWrite(LED,LOW); //Turn off LED delay(symbolSpace); //wait before the next symbol in a letter digitalWrite(LED,HIGH); //Turn on LED delay(dash); //wait one 'dash' with LED on digitalWrite(LED,LOW); //Turn off LED delay(letterSpace); //wait before the next letter in a word //S digitalWrite(LED,HIGH); //Turn on LED delay(dot); //wait one 'dot' with LED on digitalWrite(LED,LOW); //Turn off LED delay(symbolSpace); //wait before the next symbol in a letter digitalWrite(LED,HIGH); //Turn on LED delay(dot); //wait one 'dot' with LED on digitalWrite(LED,LOW); //Turn off LED delay(symbolSpace); //wait before the next symbol in a letter digitalWrite(LED,HIGH); //Turn on LED delay(dot); //wait one 'dot' with LED on digitalWrite(LED,LOW); //Turn off LED delay(wordSpace); //wait before the next word } // (c) 2024 Let's Start Coding. License: www.letsstartcoding.com/bsdlicense
 

Walkthrough Video

Watch the video for a line-by-line explanation of how the example program works. Then you'll be ready to make some changes of your own!

 

Challenges

Can you complete the challenges? Change the code in your code editor above. Upload your code to see the effect when you're finished. Complete a challenge? Check it off the list!


 
International Morse Code alphabet + numbers
 

TRANSFORMERS and HASBRO and all related trademarks and logos are trademarks of Hasbro, Inc. ©2024 Hasbro.

08 Button Press LED light

Button Press LED

//Press a button to turn on an LED light. Release the button to turn off the light. void setup(){ pinMode(8,OUTPUT); //LED light pinMode(6,INPUT_PULLUP); //Button } void loop(){ if(digitalRead(6)==LOW){ //If the button reading is LOW (the button is pressed)... digitalWrite(8,HIGH); //turn on the LED light } else{ digitalWrite(8,LOW); //otherwise (if the button reading isn't LOW), turn off th } } // (c) 2024 Let's Start Coding. License: www.letsstartcoding.com/bsdlicense
 

Walkthrough Video

Watch the video for a line-by-line explanation of how the example program works. Then you'll be ready to make some changes of your own!

 

Challenges

Can you complete the challenges? Change the code in your code editor above. Upload your code to see the effect when you're finished. Complete a challenge? Check it off the list!



TRANSFORMERS and HASBRO and all related trademarks and logos are trademarks of Hasbro, Inc. ©2024 Hasbro.

07 Randomosity

Randomosity

/*Use the random function to select LED pixel and color, tone, and loop delay */ #include "LEDStrip.h" //The LEDStrip.h library gives your code access to special functions exclusive to the LED Pixels LEDStrip pixels = LEDStrip(3, 13, 12); //Set up the pixels by defining how many pixels (3) and where the pixels connect to the microchip //The info inside these parentheses will never change when using Bumblebee void setup(){ pinMode(A5,OUTPUT); //set the speaker as an output } void loop() { pixels.setPixel(random(0,3),random(0,300)); //Set a random pixel including 0-3 to a random color including 0-299 pixels.draw(); //send the setPixel data to be displayed tone(A5,random(40,1200)); //play a random tone from 40 to 1199 hertz delay(random(50,500)); //Wait between 50 and 500 milliseconds before starting the loop over } // (c) 2024 Let's Start Coding. License: www.letsstartcoding.com/bsdlicense
 

Walkthrough Video

Watch the video for a line-by-line explanation of how the example program works. Then you'll be ready to make some changes of your own!

 

Challenges

Can you complete the challenges? Change the code in your code editor above. Upload your code to see the effect when you're finished. Complete a challenge? Check it off the list!


TRANSFORMERS and HASBRO and all related trademarks and logos are trademarks of Hasbro, Inc. ©2024 Hasbro.

06 Random Tones

Random Tones

/* Beep random tones on the speaker */ void setup(){ pinMode(A5, OUTPUT); //Speaker } void loop(){ tone(A5,random(40,1200)); //play a random hertz value from 40 - 1199 on the speaker delay(1000); // delay 1000 milliseconds (1 second) with the tone playing } // (c) 2024 Let's Start Coding. License: www.letsstartcoding.com/bsdlicense
 

Walkthrough Video

Watch the video for a line-by-line explanation of how the example program works. Then you'll be ready to make some changes of your own!

 

Challenges

Can you complete the challenges? Change the code in your code editor above. Upload your code to see the effect when you're finished. Complete a challenge? Check it off the list!


TRANSFORMERS and HASBRO and all related trademarks and logos are trademarks of Hasbro, Inc. ©2024 Hasbro.

05 Morse Code SOS

Morse Code Message: SOS

/*Play a Morse Code message on the speaker Rules of Morse Code: - Dots are 1 'unit' of sound - Dashes are 3 'units' of sound (3 times as long as a dot) - Spaces between symbols within the same letter are 1 'unit' of silence - Spaces between letters are 3 'units' of silence - Spaces between words are 7 'units' of silence */ void setup(){ pinMode(A5,OUTPUT); //Set the speaker as an 'OUTPUT' } void loop(){ //S //dot tone(A5,500); //play a tone of 500 hertz on the speaker (A5) delay(300); //wait one 'dot' with the speaker on noTone(A5); //turn off the sound delay(300); //wait before the next symbol in a letter //dot tone(A5,500); //play a tone of 500 hertz on the speaker (A5) delay(300); //wait one 'dot' with speaker on noTone(A5); //turn off the sound delay(300); //wait before the next symbol in a letter //dot tone(A5,500); //play a tone of 500 hertz on the speaker (A5) delay(300); //wait one 'dot' with speaker on noTone(A5); //turn off the sound delay(900); //wait before the next letter in a word //O //dash tone(A5,500); //play a tone of 500 hertz delay(900); //wait one 'dash' with speaker on noTone(A5); //turn off the sound delay(300); //wait before the next symbol in a letter //dash tone(A5,500); //play a tone of 500 hertz delay(900); //wait one 'dash' with the speaker on noTone(A5); //turn off the sound delay(300); //wait before the next symbol in a letter //dash tone(A5,500); //play a tone of 500 hertz delay(900); //wait one 'dash' with speaker on noTone(A5); //turn off the sound delay(900); //wait before the letter in a word //S //dot tone(A5,500); //play a tone of 500 hertz on the speaker (A5) delay(300); //wait one 'dot' with the speaker on noTone(A5); //turn off the sound delay(300); //wait before the next symbol in a letter //dot tone(A5,500); //play a tone of 500 hertz on the speaker (A5) delay(300); //wait one 'dot' with the speaker on noTone(A5); //turn off the sound delay(300); //wait before the next symbol in a letter //dot tone(A5,500); //play a tone of 500 hertz on the speaker (A5) delay(300); //wait one 'dot' with the speaker on noTone(A5); //turn off the sound delay(2100); //wait before the next word } // (c) 2024 Let's Start Coding. License: www.letsstartcoding.com/bsdlicense
 

Walkthrough Video

Watch the video for a line-by-line explanation of how the example program works. Then you'll be ready to make some changes of your own!

 

Challenges

Can you complete the challenges? Change the code in your code editor above. Upload your code to see the effect when you're finished. Complete a challenge? Check it off the list!


 
International Morse Code alphabet + numbers
 

TRANSFORMERS and HASBRO and all related trademarks and logos are trademarks of Hasbro, Inc. ©2024 Hasbro.

04 LED and Tone Sync

Sync Rising Brightness and Tone

// Brighten a color of the jumbo LED as the tones on the speaker rise void setup(){ pinMode(9,OUTPUT); //Color 9 of the jumbo multicolor LED pinMode(A5,OUTPUT); //Speaker } void loop(){ analogWrite(9,50); //Set pin to a brightness of 50. analogWrite range is 0 - 255 tone(A5,50); //Play a tone of 50 hertz on speaker pin (A5) delay(500); //Wait 500 milliseconds (1/2 second) analogWrite(9,150); //Set pin 9 to a brightness of 150 tone(A5,150); //Play a tone of 150 delay(500); analogWrite(9,250); //Set pin 9 to 250 tone(A5,250); //Play a tone of 250 delay(500); } // (c) 2024 Let's Start Coding. License: www.letsstartcoding.com/bsdlicense
 

Walkthrough Video

Watch the video for a line-by-line explanation of how the example program works. Then you'll be ready to make some changes of your own!

 

Challenges

Can you complete the challenges? Change the code in your code editor above. Upload your code to see the effect when you're finished. Complete a challenge? Check it off the list!

TRANSFORMERS and HASBRO and all related trademarks and logos are trademarks of Hasbro, Inc. ©2024 Hasbro.

03 Single Speaker Beep

Single Speaker Beep

/* Beep a tone one time. Unplug and replug your power cable to hear it again! */ void setup(){ pinMode(A5,OUTPUT); //Set pin A5 to receive power tone(A5,400); //Send a tone of 400 hertz (hz) to the speaker delay(1000); //Delay 1000 milliseconds (1 second) with the tone playing noTone(A5); //Turn off any tones playing } void loop(){} //Nothing in the loop, so no code will repeat // (c) 2024 Let's Start Coding. License: www.letsstartcoding.com/bsdlicense
 

Walkthrough Video

Watch the video for a line-by-line explanation of how the example program works. Then you'll be ready to make some changes of your own!

 

Challenges

Can you complete the challenges? Change the code in your code editor above. Upload your code to see the effect when you're finished. Complete a challenge? Check it off the list!

TRANSFORMERS and HASBRO and all related trademarks and logos are trademarks of Hasbro, Inc. ©2024 Hasbro.

02 Blink All Rainbow LED Pixels

Blink All LED Pixels

/* Blink all of the rainbow pixels on and off once per second */ #include "LEDStrip.h" //The LEDStrip.h library gives your code access to special functions exclusive to the LED pixels LEDStrip pixels = LEDStrip(3, 13, 12); //Set up the pixels by defining how many pixels (3) and where the pixels connect to the microchip //The info inside these parentheses will never change when using Bumblebee void setup() {}//nothing needed in the setup! void loop() { pixels.setPixel(pixels.All, 200); //use pixels.All in the place where the pixel number normally goes, then the color (0-300) pixels.draw(); //Send the setPixel values to Bumblebee delay(1000); //Wait 1000 milliseconds (1 second) with the pixels lit up pixels.clear(); //pixels.clear() sets all the pixels to have no color value (turned off) pixels.draw(); //Send the pixels.clear() values to Bumblebee delay(1000); //Wait 1000 milliseconds before starting the loop again } // (c) 2024 Let's Start Coding. License: www.letsstartcoding.com/bsdlicense
 

Walkthrough Video

Watch the video for a line-by-line explanation of how the example program works. Then you'll be ready to make some changes of your own!

LED Pixel Color Spectrum


Use this spectrum to estimate the color values you'll need for your 'setPixel' arguments to achieve your favorite color!


 

Challenges

Can you complete the challenges? Change the code in your code editor above. Upload your code to see the effect when you're finished. Complete a challenge? Check it off the list!

TRANSFORMERS and HASBRO and all related trademarks and logos are trademarks of Hasbro, Inc. ©2024 Hasbro.

01 Change Bumblebee's Eye Color

Change Bumblebee's Eye Color

/* Turn on Bumblebee's LED eyes */ #include "LEDStrip.h" //The LEDStrip.h library gives your code access to special functions exclusive to the LED pixels LEDStrip pixels = LEDStrip(3,13,12); //Set up the pixels by defining how many pixels and which pins of the microchip are used (always 13 and 12 on a Transformer) void setup(){} //Nothing in the void setup function, but it still needs to be here. void loop() { pixels.setPixel(0,222); //set LED pixel 0 (right eye) to a color value of 222 pixels.setPixel(1,111); //set LED pixel 1 to color 111 pixels.draw(); //send the color values to the LED pixels } //(c)2024 Let's Start Coding. License: www.letsstartcoding.com/bsdlicense
 

Walkthrough Video

Watch the video for a line-by-line explanation of how the example program works. Then you'll be ready to make some changes of your own!

LED Pixel Color Spectrum


Use this spectrum to estimate the color values you'll need for your 'setPixel' arguments to achieve your favorite color!


 

Challenges

Can you complete the challenges? Change the code in your code editor above. Upload your code to see the effect when you're finished. Complete a challenge? Check it off the list!

TRANSFORMERS and HASBRO and all related trademarks and logos are trademarks of Hasbro, Inc. ©2024 Hasbro.

Bumblebee Projects Page

00 Plug in and Set Up Bumblebee

Plug in and Set Up Bumblebee

//Run a test program on your Transformer Bot void setup(){ pinMode(8,OUTPUT); pinMode(10,OUTPUT); } void loop(){ digitalWrite(8,HIGH); digitalWrite(10,LOW); delay(500); digitalWrite(10,HIGH); digitalWrite(8,LOW); delay(500); } //(c)2024 Let's Start Coding. License: www.letsstartcoding.com/bsdlicense
 
 
 

Having trouble? We recommend revisiting the start page, where you’ll find steps to check and a contact form if you need more help.

TRANSFORMERS and HASBRO and all related trademarks and logos are trademarks of Hasbro, Inc. ©2024 Hasbro.