Show Posts
|
|
Pages: [1]
|
|
2
|
Using Arduino / Project Guidance / Re: $150 Happy Birthday to you?
|
on: December 30, 2012, 06:27:22 pm
|
Got your Batman theme! It is not much but here it is anyways /* Pelle Jansen - 30-12-2012 *Play Happy Birthday * * The circuit: * base of NPN transistor thrugh 500R(depends on transistor used) to pin 13, * Emitter of NPN transistor to ground * Collector to speaker negative * speaker positive to VDD * can also use mosfet. */ // includes and defines: #include "pitches.h" // most used notes as defined frequencies
// constant var defenitions: const unsigned char button=2; const unsigned char spk=13;
// Variable and function defenitions: int Batman[] = { NOTE_A3, NOTE_A3, NOTE_GS3, NOTE_GS3, NOTE_G3, NOTE_G3, NOTE_GS3, NOTE_GS3, NOTE_A3, NOTE_A3, NOTE_GS3, NOTE_GS3, NOTE_G3, NOTE_G3,NOTE_GS3, NOTE_GS3, NOTE_A3, NOTE_A3, NOTE_GS3, NOTE_GS3, NOTE_G3, NOTE_G3, NOTE_GS3, NOTE_GS3, NOTE_A3, NOTE_A3, NOTE_GS3, NOTE_GS3, NOTE_G3, NOTE_G3,NOTE_GS3, NOTE_GS3, NOTE_E4, NOTE_E4 }; unsigned char length=sizeof(Batman)/2; // note durations: 4 = quarter note, 8 = eighth note, etc.: int noteDurations[] = { 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 4, 4,8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 4, 4, 4, 4}; unsigned char lengthDur=sizeof(noteDurations)/2;
// Set up the microcontroller void setup(){ Serial.begin(9600); Serial.println("Serial active! "); pinMode(button, INPUT_PULLUP); }
// play the song void play(){ // check if there are as much notes as durations if (length != lengthDur){ Serial.println("ERROR: note durations not equal to number of notes! "); Serial.print("Length of Batman: "); Serial.print(length); Serial.print("; Length of durations: "); Serial.println(lengthDur); } // iterate over the notes of the Batman: for (unsigned char thisNote = 0; thisNote < length; thisNote++) { // to calculate the note duration, take one second divided by the note type. //e.g. quarter note = 1000 / 4, eighth note = 1000/8, etc. int noteDuration = 1000/noteDurations[thisNote]; tone(spk, Batman[thisNote],noteDuration); Serial.print("Current frequency: "); Serial.println(Batman[thisNote]); // to distinguish the notes, set a minimum time between them. // the note's duration + 30% seems to work well: int pauseBetweenNotes = noteDuration * 1.30; delay(pauseBetweenNotes); noTone(spk); // stop the tone playing: } }
// main loop void loop(){ // play the song // to not repeat: move play() to setup() and remove delay play(); delay(1000); // Slow repetition }
I'm sorry I'm a noob, but what hardware would I use this code for? Be patient I'm learning
|
|
|
|
|
3
|
Using Arduino / Project Guidance / Re: $150 Happy Birthday to you?
|
on: December 30, 2012, 06:24:57 pm
|
Is there a simpler cheaper way to do this? but another card ? Holy Hairballs Robin why didn't I think of that! Ha I mean, how can I build something like this from scratch to play my theme song 007 in a loop without spending 150 on the whole rig  Thanks for all your replies btw!
|
|
|
|
|
4
|
Using Arduino / Project Guidance / $150 Happy Birthday to you?
|
on: December 30, 2012, 03:27:38 pm
|
|
So I got a sweet Batman Birthday card that plays a short clip of the Bat Theme when I open it. Then I cut the card open with my knife cause I wanted to see how they did it. So my question is I want to make something like this that has a simple trigger that will play one sound when the switch is opened, but so far the only thing I've seen is I have to buy a MEGA attached to a MP3 Shield etc and $150 later I have the same thing that this $5 card came with. Is there a simpler cheaper way to do this? Cheers
|
|
|
|
|
6
|
Using Arduino / Project Guidance / 007 James Bond Mod Help
|
on: December 20, 2012, 02:18:52 pm
|
|
Im looking to recreate the effects that the International Spy Museum in D.C. has on display of their Aston Martin DB5. I can wire, and solder, but not to good with programing end. What parts list would you recommend to achieve the following: push a momentary switch that will activate 2 linear actuators that push the headlights down and activate a group of LEDs that flash with the mp3 sound of guns firing. Then everything stops when the button is released. Cheers JB
|
|
|
|
|