3 Simple Ways to
Share What You Make

With Instructables you can share what you make with the world — and tap into an ever-growing community of creative experts.

PhotosPhotos

Share one or more photos of a project, recipe, or whatever you've made, quickly and easily.

Step by StepStep-By-Step

Share your step-by-step photos with text instructions of what you made so others can do it too!

VideoVideo

Share your how-to video. You'll need your embed code from a video site such as YouTube.

Singing Lazy Susan (Crazy Adam) with Hand-made Sensor Brush.

Step 8Arduino, Speaker, and Code

Arduino, Speaker, and Code
Now Connect the hand-made brush sensor and a speaker to Arduino board.
The code is as follows:

int noteIndex=999;
int sensorPin = 2; // select the input pin for the potentiometer
int speakerPin = 9;
int sensorValueOld = PI ;
int sensorValue = 0; // variable to store the value coming from the sensor
int length = 15; // the number of notes
char notes[] = "cDfcDFfDc"; // a space represents a rest
int beats[] = { 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 };
int tempo = 300;

void playTone(int tone, int duration) {
for (long i = 0; i < duration * 1000L; i += tone * 2) {
digitalWrite(speakerPin, HIGH);
delayMicroseconds(tone);
digitalWrite(speakerPin, LOW);
delayMicroseconds(tone);
}
}

void playNote(char note, int duration) {
char names[] = {
'c', 'C', 'd', 'D', 'e', 'f', 'F', 'g', 'G', 'a', 'A', 'b','S'};
int tones[] = {
1915, 1804, 1700, 1607,
1519, 1432, 1351, 1275,
1204, 1136, 1073, 1014, 956 };

// play the tone corresponding to the note name
for (int i = 0; i < 8; i++) {
if (names[i] == note) {
playTone(tones[i], duration);
}
}
}

void setup() {
// declare the ledPin as an OUTPUT:
pinMode(speakerPin, OUTPUT);

pinMode(sensorPin, INPUT);
digitalWrite(sensorPin,HIGH);

Serial.begin(9600);

}

void loop() {
// read the value from the sensor:
sensorValue = digitalRead(sensorPin);
if(sensorValueOld == sensorValue){
// do nothing!

} else { // value has changed! Lazy Susan has moved!

Serial.println(sensorValue);

// point to next note in sequence
noteIndex++;
if(noteIndex>=strlen(notes)){noteIndex=0;}
playNote(notes[noteIndex], beats[noteIndex] * tempo);
delay(tempo / 2);

}
sensorValueOld = sensorValue;

/*
if (sensorValue != 0){
for (int i = 0; i < length; i++) {
if (notes[i] == ' ') {
delay(beats[i] * random(PI,tempo)); // rest
}
else {
playNote(notes[i], beats[i] * tempo);
}

// pause between notes
delay(tempo / 2);
}

}
*/
}

« Previous StepDownload PDFView All StepsNext Step »
2 comments
Oct 21, 2009. 4:17 AMsorayamayu says:
alo-hello~!!! I was thinking of copying your singing lazy susan for our project... it's really very hard to find the things that you used in your project like the arduino, and the foam board.... and all of the things you used in step 7.... i'm really having a hard time making our project... could you please provide me with some necessary items that can be bought anywhere with a cheaper price...? i really need an alternative since we're going to make our project as an automatic singing lazy susan.. we'll be using servos in order to make the lazy susan spin... could you suggest another alternative for that? since i've looked everywhere for a servo .... i didn't find anything... someone suggested that i should use a dynamo from a toy... but could that actually work? since the tray might be too heavy...

and also... someone suggested that i should even use a motor from an electric fan or from a ceiling fan in order to make it spin... my teacher told us that any engine's speed can be reset from slow to fast.. so... should i stick with this idea? since the materials are too hard to find?

kindly reply soon... i really really really need your help~!!!! i hope you can really help me though,... firthermore, thank you for working on with such a nice project~! it really really inspired me to do so much~!

LOVE,

Soraya Danica D. Dimayuga, age 16, from the philippines
Jul 21, 2010. 5:25 AMLuziviech says:
Bought my own board from a private seller on ebay now, but there are also other sellers from Asia like China who sell those boards on ebay, even shields, partially without charging shipping costs; those guys seem to be international vendors, so i guess there'd be no prob for you to get one there.

Pro

Get More Out of Instructables

Already have an Account?

close

All Steps Viewing
View all steps of an Instructable on the same page when you're a Pro Member.

Upgrade to Pro today!
1
Followers
1
Author:Aithne Pao