MakerFaire and sound/light project

 

Three projects I found interesting at MakerFaire:

I am interested in folding and origami and this project combined that with the ability to mechanically unfold and fold back flat again:

026

This project combined sound and light. Each acrylic tube had a sensor on top and correlated to a note and lighting effect. The sound quality was not bad and the lighting through the material used created a nice effect. It was only 7 notes though so it would be nice to be expanded to really create music:

 

041

 

 

This was a modular set of lights that you could pin together as you pleased. There was a base providing initial charge and I think they could be removed from that base and had some battery storage ability. I didn’t think the fabrication or aesthetic component was of a really high standard but it’s an interesting idea:

0301

 

My project for this week is a night light/music box for a child. When you switch it on, it plays a lullaby and the light comes on. As the melody plays the light dims until the tune ends and the light is off.

http://www.youtube.com/watch?v=YTbKSK98DwY

I think the code could be a bit cleaner with the fading but I’m not sure how. Perhaps one way would be to create a variable that tracks time and then a function for the analog write which relates the brightness of the light to the time elapsed as a proportion of the total time.

 

/* lullaby_switch_dimming
*
* Each time the input pin goes from LOW to HIGH (e.g. because of a push-button
* press), the melody begins and the light goes on. As the melody progresses the
* light fades until it goes completely off with the end of the melody.
*
*/
#include “pitches.h”

int inPin = 2; // the number of the input pin
int outPinled = 9; // the number of the output pin for the LED
int outPinspeaker = 7; // the number of the output pin for the speaker
int brightness = 255;
int fadeAmount = 5;

void setup() {
pinMode (inPin, INPUT);
pinMode (outPinled, OUTPUT);
pinMode (outPinspeaker, OUTPUT);
}

void loop() {
reading = digitalRead(inPin);

if (reading == HIGH) {
analogWrite(outPinled, 255);
tone(outPinspeaker, NOTE_E5);
delay(200);
analogWrite(outPinled, 245);
noTone(outPinspeaker);
delay(50);
analogWrite(outPinled, 235);
tone(outPinspeaker, NOTE_E5);
delay(250);
analogWrite(outPinled, 205);
tone(outPinspeaker, NOTE_G5);
delay(1000);
analogWrite(outPinled, 195);
tone(outPinspeaker, NOTE_E5);
delay(250);
analogWrite(outPinled, 185);
noTone(outPinspeaker);
delay(50);
analogWrite(outPinled, 175);
tone(outPinspeaker, NOTE_E5);
delay(250);
analogWrite(outPinled, 165);
tone(outPinspeaker, NOTE_G5);
delay(1000);
analogWrite(outPinled, 160);
tone(outPinspeaker, NOTE_E5);
delay(250);
analogWrite(outPinled, 155);
tone(outPinspeaker, NOTE_G5);
delay(250);
analogWrite(outPinled, 150);
tone(outPinspeaker, NOTE_C6);
delay(500);
analogWrite(outPinled, 145);
tone(outPinspeaker, NOTE_B5);
delay(750);
analogWrite(outPinled, 140);
tone(outPinspeaker, NOTE_A5);
delay(200);
analogWrite(outPinled, 135);
noTone(outPinspeaker);
delay(50);
analogWrite(outPinled, 130);
tone(outPinspeaker, NOTE_A5);
delay(500);
analogWrite(outPinled, 125);
tone(outPinspeaker, NOTE_G5);
delay(500);
analogWrite(outPinled, 120);
tone(outPinspeaker, NOTE_D5);
delay(250);
analogWrite(outPinled, 116);
tone(outPinspeaker, NOTE_E5);
delay(250);
analogWrite(outPinled, 112);
tone(outPinspeaker, NOTE_F5);
delay(500);
analogWrite(outPinled, 108);
tone(outPinspeaker, NOTE_D5);
delay(450);
analogWrite(outPinled, 104);
noTone(outPinspeaker);
delay(50);
analogWrite(outPinled, 100);
tone(outPinspeaker, NOTE_D5);
delay(250);
analogWrite(outPinled, 96);
tone(outPinspeaker, NOTE_E5);
delay(250);
analogWrite(outPinled, 92);
tone(outPinspeaker, NOTE_F5);
delay(1000);
analogWrite(outPinled, 88);
tone(outPinspeaker, NOTE_D5);
delay(250);
analogWrite(outPinled, 84);
tone(outPinspeaker, NOTE_F5);
delay(250);
analogWrite(outPinled, 80);
tone(outPinspeaker, NOTE_B5);
delay(250);
analogWrite(outPinled, 76);
tone(outPinspeaker, NOTE_A5);
delay(250);
analogWrite(outPinled, 72);
tone(outPinspeaker, NOTE_G5);
delay(500);
analogWrite(outPinled, 68);
tone(outPinspeaker, NOTE_B5);
delay(500);
analogWrite(outPinled, 64);
tone(outPinspeaker, NOTE_C6);
delay(950);
analogWrite(outPinled, 60);
noTone(outPinspeaker);
delay(50);
analogWrite(outPinled, 57);
tone(outPinspeaker, NOTE_C5);
delay(200);
analogWrite(outPinled, 54);
noTone(outPinspeaker);
delay(50);
analogWrite(outPinled, 51);
tone(outPinspeaker, NOTE_C5);
delay(250);
analogWrite(outPinled, 48);
tone(outPinspeaker, NOTE_C6);
delay(1000);
analogWrite(outPinled, 45);
tone(outPinspeaker, NOTE_A5);
delay(250);
analogWrite(outPinled, 42);
tone(outPinspeaker, NOTE_F5);
delay(250);
analogWrite(outPinled, 39);
tone(outPinspeaker, NOTE_G5);
delay(1000);
analogWrite(outPinled, 36);
tone(outPinspeaker, NOTE_E5);
delay(250);
analogWrite(outPinled, 33);
tone(outPinspeaker, NOTE_C5);
delay(250);
analogWrite(outPinled, 30);
tone(outPinspeaker, NOTE_F5);
delay(500);
analogWrite(outPinled, 28);
tone(outPinspeaker, NOTE_G5);
delay(500);
analogWrite(outPinled, 26);
tone(outPinspeaker, NOTE_A5);
delay(500);
analogWrite(outPinled, 24);
tone(outPinspeaker, NOTE_E5);
delay(500);
analogWrite(outPinled, 22);
tone(outPinspeaker, NOTE_G5);
delay(500);
analogWrite(outPinled, 20);
tone(outPinspeaker, NOTE_C5);
delay(200);
analogWrite(outPinled, 18);
noTone(outPinspeaker);
delay(50);
analogWrite(outPinled, 16);
tone(outPinspeaker, NOTE_C5);
delay(250);
analogWrite(outPinled, 14);
tone(outPinspeaker, NOTE_C6);
delay(1000);
analogWrite(outPinled, 12);
tone(outPinspeaker, NOTE_A5);
delay(250);
analogWrite(outPinled, 10);
tone(outPinspeaker, NOTE_F5);
delay(250);
analogWrite(outPinled, 9);
tone(outPinspeaker, NOTE_G5);
delay(1000);
analogWrite(outPinled, 8);
tone(outPinspeaker, NOTE_E5);
delay(250);
analogWrite(outPinled, 7);
tone(outPinspeaker, NOTE_C5);
delay(250);
analogWrite(outPinled, 6);
tone(outPinspeaker, NOTE_F5);
delay(250);
analogWrite(outPinled, 5);
tone(outPinspeaker, NOTE_G5);
delay(125);
analogWrite(outPinled, 4);
tone(outPinspeaker, NOTE_F5);
delay(125);
analogWrite(outPinled, 3);
tone(outPinspeaker, NOTE_E5);
delay(500);
analogWrite(outPinled, 2);
tone(outPinspeaker, NOTE_D5);
delay(500);
analogWrite(outPinled, 1);
tone(outPinspeaker, NOTE_C5);
delay(1000);
analogWrite(outPinled, 0);
noTone(outPinspeaker);
digitalWrite(outPinled, LOW);
delay(10000);
}
else
noTone(outPinspeaker);
digitalWrite(outPinled, LOW);
}