PComp – HW 3

This week’s assignment:

Make a thing that outputs light and sound.
Use the PWM output with the analogWrite() command, and make tones with the tone() command.
Use multiple LEDs and mix the colors of the light.
Find some material that the light will diffuse through to help blend the colors.”

I began by setting up a circuit of buttons attached to LEDs. I then played around with some of the tone() tutorials from the Arduino website and figured out how to play sound through the speaker. See the photo and video below of what I set up

Buttons, LEDs, and Sound from Tami on Vimeo.

I decided to code a song instead of using button input, in order to have more control of the ultimate output. I looked up the chords for “Twinkle Twinkle Little Star”, and tried to put those notes into an array in order to play the song. I was able to get the timing correct and the LEDs to light up along with the melody, but the tones do not sound exactly as I thought they would. I had to change some of the notes because it was hard to distinguish between some of the tones.

I then played with the analogWrite function to achieve a fading effect with the LEDs. By making the fade value increase by a larger number every time the for loop is run, the LEDs fade at a faster rate, both from dark to bright and back from bright to dark.

My last step was to mix colors of the LEDs. I decided to attach two LEDs to one pin on the Arduino board, but that proved to be more difficult than I had anticipated. I learned (through trial and error) that it is possible to have two LEDs attached to the same power source, but they need to be grounded separately. I was able to get a blue LED and red LED flashing/fading together, so the final step was to diffuse them. I had nothing interesting handy to diffuse the light, so I created a paper cover for the lights that helps diffuse them. I will be looking around for something more interesting to use in the future, like foam or fabric.

Take a look at my code, as well as the pitches.h file.

LEDs not diffused

Audio and LEDS from Tami on Vimeo.

LEDs diffused

Audio and Diffused LEDs from Tami on Vimeo.

One thought on “PComp – HW 3

  1. Pingback: pcomp, class 4; rebuilding Tami’s lights/sounds » warman

Comments are closed.