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.