image_pdfDownload as PDFimage_printPrint

You know someone whose birthday is approaching near but you dont know what to gift, well i might have a good idea.

Birthday RGB Baloons

This is simple trick but it looks awesome. You just have to attach different colors of leds with 3v coin cell and put them in ballons.
Here are some tips;

 

 

Birthday tune card

Second idea is to put a circuit in the birthday card that will play birthday tune when opened.
So we are going to do this. For playing tune we could use piezo electric disk. It also very thin perfect for our condition. But how are we going to drive it, well i use Digispark which consist of attiny 85 microcontroller. It is also small in size and can be programmed using Arduino IDE. We will power all this circuit using coin cell. Now the only question remain how are we going to detect when it is touched.
here we have different options some of which are;

  1. LDR
  2. TOUCH
  3. FLEX sensor
  4. Hall effect sensor
  5. Vibration sensor

I personally liked the flex sensor method but here i have another plan. Using Vibration sensor, but why you might be asking. Well we already have vibration sensor in a form of knock sensor. So what is knock sensor. Arduino website have a good explanation for that but in a nutshell we will use piezo electric to detect vibration. Piezo electric disk can actually produce voltage when vibrated.
So here is our plan we will first read the voltage from piezo and when it reaches a target threshold we will stop listening and start playing birthday tune on it.
There is one another interesting thing we can do, we can use single pin to do both reading and playing tune to piezo disk. We will use pin 2 of attiny85 to do this job. We could use other pins but i prefer this pin as this pin is not connected to any led or is not used by usb communication.
Here is code for attiny85

int length = 28; // the number of notes
char notes[] = "GGAGcB GGAGdc GGxecBA yyecdc";
int beats[] = { 2, 2, 8, 8, 8, 16, 1, 2, 2, 8, 8,8, 16, 1, 2,2,8,8,8,8,16, 1,2,2,8,8,8,16 };
int tempo = 150;
int buzzer =2;
void setup() {
  // put your setup code here, to run once:
//Serial.begin(9600);
}

void loop() {
  // put your main code here, to run repeatedly:
//Serial.println(analogRead(knock));
  pinMode(buzzer,INPUT);
if(analogRead(1) > 100){
  pinMode(buzzer,OUTPUT);
  for (int i = 0; i < length; i++) {
   if (notes[i] == ' ') {
     delay(beats[i] * tempo); // rest
   } else {
     playNote(notes[i], beats[i] * tempo);
   }
   // pause between notes
   delay(tempo);
    }    
  }
}

void playNote(char note, int duration) {
char names[] = {'C', 'D', 'E', 'F', 'G', 'A', 'B',  'c', 'd', 'e', 'f', 'g', 'a', 'b',  'x', 'y' };
int tones[] = { 1915, 1700, 1519, 1432, 1275, 1136, 1014, 956, 834,  765,  593,  468,  346,  224,  655 , 715 };
int SPEE = 5;
// play the tone corresponding to the note name
for (int i = 0; i < 17; i++) {

   if (names[i] == note) {
    int newduration = duration/SPEE;
     playTone(tones[i], newduration);
   }
}
}

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

If you are wondering where i got this code from i got it from here

Here is working demo of it;

https://drive.google.com/file/d/1aaQQ1EEKWLTJ1O6Mu5NGJT2mOlBdaxaV/view?usp=sharing