Blow OFF the LED

by chienline in Circuits > LEDs

4565 Views, 31 Favorites, 0 Comments

Blow OFF the LED

20161010_182151A.jpg

My kids are wondering and curious about the digital candle in my Rusty Candle Lamp. They love watching the light of flickering LEDs. The next day I showed them, my eldest son asked "Can we blow off the candle?".

"Hah? This is digital candle. We can't blow it off. Simply unplugged the power, " I replied.

"Candle should be blown off, isn't it?" He insisted.

Last week I ran into an electret microphone amplifier circuit. The circuit is interesting. The parts used are simple and easy to get, and I have them all ready in hand. This circuit reminds me to my son's question : "Can we blow off the candle?". This might be able to hear my blowing "Huff!" sound. And yes it can ^^

Then I showed them this video.

Well.. let's take a look on the parts list.

BOM : Bill of Materials

DSC_0149.JPG
  • An Arduino Uno or compatible.
  • A mini breadboard.
  • 1 piece of Push Button.
  • 4 pieces of 10K resistor.
  • 1 piece of 100K resistor.
  • 1 piece of NPN resistor, I use BC548.
  • 2 pieces of 100nF capacitor.
  • 1 piece of electret microphone.
  • Some male to male jumper wires (7 to 9 pieces are enough).
  • 1 piece of LED (or you can use the onboard LED on pin 13).

Circuit Diagram

DSC_0189.JPG

Here is the circuit diagram. I drew it with hand because there was blackout at the moment I was writing this instructables. I enjoyed drawing it ^^

You might notice that there is no LED on the diagram. Well, it is plugged into Arduino digital pin 13. Why pin 13? Because there is a GND pin next to it. So plug the anode of LED into pin 13 and cathode of LED into GND pin next to it. It doesn't matter if you can't find a LED around. Arduino Uno has a built-in LED on the board on pin 13. That's the fun of playing with Arduino Uno ;)

Power Rails

DSC_0150.JPG

I try a different approach to deliver circuit wiring instructions. From this step forward, I will show you how to place part by part on the mini breadboard and wiring it to Arduino. Just follow/count the hole position to avoid wrong connection. The photos tell your everything but I still provide some text in case they don't. Well, you can place them on your liking though, according to the circuit diagram :D

Mini breadboard doesn't have a dedicated power rails like those on half size and full size breadboard which have "+" and "-" marks on them. And we will connect several parts on 5V and GND, so we need more holes. I always join the top rail to the bottom rail, so now we have 8 holes for each 5V and GND. You can do this with a jumper wire, but I use two pieces of short wire because I always need this all the time when working with circuits ^^

The NPN Transistor

DSC_0151.JPG
DSC_0152.JPG

Any NPN transistor will do. Here in this project I used BC548.

Place it in the middle of second row from top.

The First 10K Resistor

DSC_0153.JPG

Place a 10K resistor on the first row, from 5V rail to transistor's collector.

The First 100nF Capacitor

DSC_0154.JPG

Place the right lead of a 100nF capacitor in front of transistor's collector.

The Second 10K Resistor

DSC_0155.JPG

Place the second 10K resistor from left lead of the first 100nF capacitor to the ground rail.

The 100K Resistor

DSC_0156.JPG

Place the 100K resistor vertically from transistor's collector to transistor's base in front of the first 100nF capacitor.

The Second 100nF Capacitor

DSC_0157.JPG

Place the second 100nF capacitor from transistor's base to the hole below it crossing the gutter in the middle of the breadboard.

The Third 10K Resistor

DSC_0158.JPG

Place the third 10K resistor from the second 100nF capacitor to the 5V power rail.

The Electret Microphone

DSC_0159.JPG

Place the positive leg of the electret mic below the second 100nF capacitor, and the negative leg next to it on the right side.

The Push Button

DSC_0160.JPG

Place the push button on the right side of the breadboard, in the middle row crossing the breadboard's gutter. If you are using a half or full size breadboard, put the button as far as possible from the microphone, because your button's click can be heard by mic and it will turn off the LED if you don't add "treshold" in your code :D

The Fourth 10K Resistor

DSC_0161.JPG

Place the fourth 10K resistor from the button's right lower pin to ground rail.

The First Wire

DSC_0162.JPG

Connect black wire from transistor's emitter to Ground rail.

The Second Wire

DSC_0163.JPG

Connect black wire from electret mic's negative lead to Ground rail.

The Third Wire

DSC_0164.JPG

Connect a red wire from button's upper left pin to 5V rail.

The Arduino Uno

DSC_0167.JPG

Place your Arduino Uno (or compatible) board below the breadboard.

The Fourth Wire

DSC_0168.JPG

Connect a green wire from button's upper right pin to Arduino digital pin 2.

The Fifth Wire

DSC_0169.JPG

Connect a blue wire from the left lead of the first 100nF capacitor to Arduino analog pin A0.

The Sixth and the Seventh Wire

DSC_0170.JPG

Connect a black wire from breadboard's Ground rail to Arduino GND pin.

Connect a white wire from breadboard's 5V rail to Arduino 5V pin.

The LED

DSC_0171.JPG

Plug a LED. Anode (small piece inside/long lead) to Arduino digital pin 13. Cathode (large piece inside/short lead) to Arduino GND pin next to pin 13.

Arduino Sketch

Copy this code and paste it on your Arduino IDE then upload the sketch to your board.

/* 
  *  Turn on the LED with a button
  *  Then blow off the LED just like blowing off a candle
  *  By Chienline @2016
*/

int buttonState = 0; 
int micValue = 0;

void setup() {
  pinMode(13, OUTPUT); // LED on digital pin 13
  pinMode(2, INPUT);   // Button on digital pin 2
  pinMode(A0, INPUT);  // Microphone read at analog pin 0
}

void loop() {
  buttonState = digitalRead(2); // Check the button state
  if (buttonState == HIGH){
    digitalWrite(13, HIGH); // Turn on the LED
  }
  if (analogRead(A0) > micValue){ //Check the microphone state
    digitalWrite(13, LOW); // If sound is detected, turn off the LED
  }
  micValue = analogRead(A0);
}

Power on and Test

DSC_0173.JPG
DSC_0175.JPG

Power on your Arduino and test your circuit. Turn on the LED with the push button. Then BLOW it off ... Huff! Don't forget to test the SNAP it off and CLAP it off :D

Another way to turn the old fashion way into digital :D