There was a question in my head, if morse code can be used by eyes then... I can make a music with that. Morse code is of some pattern, music is also some patterns of sound or bit (Have a little knowledge in that). Then I thought if we can wink in a pattern we can definitely generate music, at least we can synthesize that pattern. That's what I've tried to do in this project. I tried to make music using eyes.
Let's see how we can do that.
Step 1: Parts You'll Need
- Arduino pro mini - I've used the ATmega328p 5v 16 mHz one
- IR sensor (without ADC board)
- Speaker - I've taken it from old phone
- Powerbank Module - booster
- Small lipo battery - I used a 150 mAh battery
Step 2: Principle
So, I've used two ir sensors to see if eyes are closed or open. Each IR sensor outputs some data (0 to 1023). Now if it sees any closed eye the value decreases thus it can say the corresponding Eye is closed (wink detected). You can buy Eye Blink sensor but the working functionality is all the same yet my solution is cheaper and it works.
After detecting any wink or blink it outputs a sound in a different frequency for each eye. And if both the eyes are closed another frequency. Hope you got the point.
Now lets make it.
Step 3: Build the Circuit
The circuit diagram is pretty easy and simple. You can always watch the video on top to see how I did it. Just use a ribbon cable to avoid messy wires. Then solder parts as per the circuit diagram.
Note: Use a better cable for battery connection. As you know that the resistance value increases as the wire becomes longer, so I've used a servo cable which can pass enough current to get things going. Then power it up before connecting things together.
Step 4: Upload the Program
Now as I've mentioned earlier two different frequencies are set for each eyes. This works using Tone function.
tone(speaker_name, frequency_in_Hz, delay);
To program Arduino pro mini:
- Remove the ATmega 328p IC from Arduino Uno
- Connect uno Tx to mini tx
- Uno Rx to mini rx
- Uno 5v to mini vcc
- Uno Gnd to mini gnd
- Uno Reset to mini rst
Then go to arduino.ide and select board (arduino pro mini) and port then upload the following code. You can also download or follow the code here.
/* * Making music using Eye* by: Ashraf Minhaj* mail: ashraf_minhaj@yahoo.com* license: General Public License*///connect sensors on int sen1 = A0; //A0 int sen2 = A1; //A1//Connect speakers (Not acutally buzzers) int buz1 = 8; //on digital pin 8 int buz2 = 9; //digital 9void setup() // put your setup code here, to run once: { pinMode(buz1, OUTPUT); //set pins as output pinMode(buz2, OUTPUT);Serial.begin(9600); //initialize serial com to see values}void loop() { // put your main code here, to run repeatedly:int val1 = analogRead(sen1); int val2 = analogRead(sen2);//print what's been read by the sensors Serial.println(val1);if(val1 < 750 && val2 < 750) { tone(buz1, 1000, 10); }else if(val1 < 750) { tone(buz1, 2000, 100); }else if(val2 < 750) { tone(buz1, 1500, 100); }//Serial.println(val2);//make sound}
Comments
Post a Comment