Doorknob touch alarm 28
I recently found a doorknob touch alarm schematic while browsing Discover Circuits’ archives. The project was originally intended as a present for my brother’s dorm room, but a bad capacitor and the lack of a proper oscilloscope caused delays. It has not made it off the breadboard, and it probably will not until his next semester. The circuit contains a few basic elements, an flip-flop based oscillator, a set of delays, a flip-flop as a sensor, and the audible alarm.
The schematic

The oscillator
The first section of the circuit is an oscillator based on a flip-flop. Clock and D are both grounded while Reset is tied high. Hence, the output Q will only be high if Set (node 6) is high. When the output is low, the transistor Q1* is cutoff. This allows *node 6 to be charged with a delay relating to the system of impedances R1*, *R2, R3*, and *C3. Once the voltage at node 6 triggers Set, the output changes to high and Q1* is opened. *Node 6 then discharges out through the capacitor. Once node 6 is low enough, Set is no longer triggered and the output is automatically reset (because R is tied high) to low and the process is repeated.
The screen capture below shows node 6 charging and discharging as the blue trace. The yellow trace is the output at node 1. You can see that the output turns high when node 6 reaches the switching threshold of the flip-flop (about 1.8 volts). Right afterwards it spikes up due to feedback through C2*, but quickly starts discharging. The oscillator switches off when *node 6 returns below the 1.8volt switching voltage. Feedback through C2* draws *node 6 to ground before the process repeats itself.
In order to change the period of oscillation, adjust the value at C3*. If you would like to make the pulses longer, adjust *C2. The circuit works best right where it is at, though.
The delay and ‘sensor’
The output of the oscillator is divided down two paths. The time constants of the two delays are nearly equal and can be adjusted with the sensitivity potentiometer. The path to node 11 is the Clock input of the flip-flop, and the path to node 9 determines if there is an alarm or not.
In the capture above, node 9 high than the the clock. Hence, the flip-flop stays high when the leading clock edge triggers it to lock. When the doorknob is touched, your body absorbs some of the charge and node 9 charges slower. This can be seen in the capture below. When the clock edge rises, node 9 is not high yet and low value is locked into the flip-flop.
The alarm
The designer uses an audible buzzer in order to relay the alarm. This is also my intent for the circuit, but I use a LED in my photos because you cannot see sound. They are both attached to the inverting output of the second op-amp (Q-bar) because it is high when the alarm is triggered.
There is an endless number of uses for this circuit, but I will just name a few crazy ideas:
- Using the intended buzzer for your hotel or dorm room. (This is a bit more impressive than the old sock trick.)
- Connecting the output to a relay that triggers the doorbell for you house. Just make sure to put it in parallel with your standard doorbell switch. That way you can still hear the Fed-Ex man. (This one has a major cool factor when someone opens your door.)
- Tying the output into a security or home automation system. You could have the lights turn on as soon as you touch the door handle to scare the dog away from laying on the door.
Photo Gallery
Getting started with the Atmel AVR 8
There are two major microcontrollers in the hobby domain, the popular PIC and Atmel’s AVR line. PICs are tried and true in both commercial and hobby implementations, but the Atmel AVR offers affordable programming solutions, a free development environment, a free assembler and a stable gcc toolkit that work across the entire AVR line.

Affordable Programmers
The AVR is well known for how simple it is to program. To start, you only need a few resistors and a parallel port. This will burn your code onto the microchip, but if you plan on pursuing larger projects you will need a more complex programmer with ISP support. This will enable the extra features and debugging support.
- The ultra low-cost AVR programmer uses an LPT port and a few resistors, but requires special software.
- A simple serial programmer for Linux uses several resistors and two LEDs. Programming is done with uisp.
- More complex schematics for ISP programmers that can be programmed via AVR Studio or AVR-Dude.
- A usb programmer that supports ISP.

A free development environment
AVR Studio is available directly from Atmel at no cost. It has an integrated simulator and programming software. However, there is only an assembler available. You will have to purchase more software for high level languages.
The gcc-toolkit
If you want to use C/C++, then the gcc-toolkit is available for the AVR, free. WinAVR comes loaded with a gcc, binutils, the avrdude programmer, simulavr, and more. On Linux, you will need to download the packages for your specific distribution or compile your own cross-compiler.
A great community
AVR Freaks is a site dedicated to the AVR line of microcontrollers. There is a large archive of tutorials and a very helpful forum.
Measuring the speed of light with Chocolate Chips 21
Over the past week, I’ve been really busy with exams and projects. Trying to save time by finding the speed of light on Google, I stumbled upon an extremely interesting article on measuring the speed of light with a microwave. As any decent cook knows, microwaves do not heat evenly. In fact, this article explains their heating patterns are relative to the speed of light!
Understanding how a microwave heats
As we all know, microwaves heat using electromagnetic waves. These waves are at a frequency perfect for rotating water molecules (f = 2.5 GHz). The rotating water molecules create friction and thereby heat.
Two types of electromagnetic waves
Although there are two types of electromagnetic waves, we typically only consider traveling waves. The amplitude of the wave travels forward in position over times. The following animation demonstrates the amplitude of a wave over space and time.


The waves in a microwave are not traveling. If they were, it would be nearly impossible to distinguish any uneven heating patterns!
Standing waves in a microwave
The waves in a microwave oven are standing waves. These waves are stationary in space with an amplitude changing over time.


With this demonstration, it is obvious that particular sections of the chips are heated more than others. In fact, these locations are located half of the wave’s length apart.
The physics of waves
We now know the frequency of the microwave and can presumably measure the length of the wave, but how are they related to the speed of light? Simple. Electromagnetic waves propagate through free space (like that in a microwave) at the speed of light. Therefore, their length is related directly to the speed of light by λ = c / f where λ is the wavelength, c is the speed of light, and f is the frequency of the microwave. Solving for the speed of light, c = λ * f.
Where do the chocolate chips come in?
Chocolate chips are perfect for measuring the distance between melted spots. The heat does not spread as quickly through them because they are not uniform. This means the melted spots will be smaller and you will have more time to measure before they all start to melt.

It is hard to tell from the photos, but there were distinct melting spots almost exactly 6cm apart. Remember, this is only half of the wavelength, so λ = 12cm. Plugging all the known variables into our equation, we get c = 12x10-2 * 2.5x109 = 3x108. Not bad! The true speed of light is 2.9987x108.
Notes if you replicate this experiment
- The chocolate chips only take 20-30 seconds to melt. The longer you have them in, the bigger the melted spots will be and the less time you will have to measure.
- This will not work in a microwave with a spinning carousel. In fact, the microwave spins to counteract these effects. Usually, you can just flip the carousel upside down to stop it from spinning. (Thanks Ryan)
- If you plan on putting the chips back in the bag, simply refrigerate them. Freezing causes them to stick to the plate.
- You can microwave anything that melts. (Cheese or a chocolate bar) However, chips work particularly well.
Photo gallery
A low power, long life LED flashlight circuit 16
Scouring the Internet for information on LEDs, I accidentally stumbled upon a PDF detailing a flashlight made from PVC. For the torch, he biases ultra-bright LEDs with ballast resistors as described in my LED lighting guide. This is a simple solution, but a with a slightly more complicated circuit we can extend battery life by over ten times!
Download PDF instructions for the inefficient version

Electrical losses in the flashlight
In this flashlight, each LED/resistor combination consumes 4.5volts at 30mA or about 135mWatts. The ballast resistor alone consumes 1.1volts at 30mA or about 33mWatts. Therefore, 25% of the power being drained from the batteries is lost in the resistor of each LED chain!!
Battery life
The ‘C’ size batteries in the PVC flashlight have a capacity of around 4 500mAh. If you build your flashlight with seven LEDs, there is a constant current drain of 7 * 30mA or 210mA. Dividing this into our battery capacity, it becomes obvious this flashlight will only stay lit for about a day. This is a far cry from the 50-100 hours claimed by commercial flashlights running on smaller ‘AA’ batteries.
Cutting your losses
As mentioned above, the ballast resistors are wasting 25% of our battery power. Electronic Design proposed a simple circuit to resolve this in a recent article. The front end of their circuit draws less than a milliamp of extra current.

The circuit is best described in two parts: one, the boost circuit function of Q1 and Q2, and two, the control circuit of Q3 and JFET1. Assume Q1 is off. With the battery voltage slightly above Q2’s VVB, a positive Q2 base current [iB = (battery voltage VBE)/RJET1] would flow. Q2 turns on, which switches inductor L1 to ground.
The end result is a 23volt pulse (as shown in Figure 2) across the series of ultra-bright LEDs. At 278kHz, the human eye cannot distinguish the difference between these pulses and a constantly lit LED. This saves even more battery power.
As the battery voltage decreases, the pulses become further apart. The brightness remains indistinguishable until the voltage falls near 2volts. (The circuit does not function well below 2volts) I doubt the PVC flashlight has this efficiency near the end of its life.
The extended battery life
According to Electronic Design, this circuit consumes an current equivalent to about 17mA. Powered by our ‘C’ cell in the PVC, this circuit could run for 265 hours! This is ten times the original PVC design.
DIY LED lighting Guide 24
LED lighting is becoming increasingly popular in fish tanks, case mods, and even household lighting. This article intends to be a comprehensive guide to their advantages, powering them, and creating dimming solutions.
- Why use LED lighting?
- Powering your LEDs with a DC source
- Using an AC source to drive LEDs
- Dimming your LEDs (with PWM)
- Purchasing LEDs

Why use LED lighting?
LED lights are extremely efficient compared to standard incandescent lighting. No other lighting source outputs as many lumens per watt. They are particularly efficient at producing a single color of light. Other light sources have to produce the entire spectrum and optically filter out unwanted colors. However, LEDs can be manufactured to produce only one wavelength of light. This makes them particularly useful in stop lights.
Another advantage to LEDs is their operating temperature. Most available today can be function for hours and remain cool to the touch. Directionality is another key property. They only emit light over a relatively small angle. This can be advantageous for reading lights, but hinders performance when attempting to light an entire room.
If the advantages of LED lighting interest you, Myths Busted, LED Lighting is an excellent article by a researcher in outdoor lighting solutions. (And the source of most my information.)
Powering your LEDs with a DC source
Warning: Driving your LEDs with too much current will permanently disable them.
If you attach LEDs directly to an unlimited power source, they naturally draw enough current to blow themselves out. Therefore, the driving current must be limited with a resistor. The relationship as described by Ohm’s Law, is V = I*R where V is the voltage over the resistor, I is the driving current, and R is the limiting resistor. Two example circuits are shown below. These particular LEDs are rated at 25mA and are powered by a 12 volt regulated supply.

Each white LED gives a voltage drop of 3.6 volts. As an example for a 12 volt light, you can run a maximum of 3 white LEDs in series at full power (3.6 x 3 = 10.8 volts drop). Subtract this from your supply voltage of 12 volts to get the additional voltage that must be dropped (in this case, 12 - 10.8 = 1.2 volts of additional drop needed). In this case, 1.2 volts of additional drop / .025 amps (25 ma) = 48 ohms… resistors are rated in watts. So in this case, 1.2 volts x .025 amps = 0.03 watts. A 1/4 watt resistor would work fine.
The tutorial above also explains how to construct a 12 volt voltage regulator from any 12+ volt DC source. Voltage regulation is highly recommended because large shifts in your driving voltage can cause the driving current to increase and burn out your LEDs!
If you are in doubt of your calculations, use one of the many LED resistor calculators.
Using an AC source to drive LEDs
It is also possible to convert an AC source to DC. My favorite way to accomplish this is with a bridge rectifier as shown below. As an added bonus, R is easily calculated using the method above.

In operation, a DC voltage of around 170 is produced from the bridge rectifier and 50uF capacitor. The capacitor value is not critical and can be anything from 20uF or more… To find the resistor value and wattage, multiply the number of LEDs by the individual LED voltage. Then subtract this number from 170 and divide the result by the desired current (usually 20 milliamps).
Dimming your LEDs (with PWM)
Using pulse width modulation (PWM) to dim your LEDs is extremely important! Simply decreasing the input voltage yields unreliable results and potentially reduces their life-span. Pulse width modulation basically pulses the source voltage on and off so quickly that your eye is unable to distinguish the difference.
PWM can be implemented using a variety of methods. The simplest is switching on/off the output of a microcontroller. There are also several circuits that implement PWM. My favorite method uses two comparators. The details are excruciatingly painful and may deserve their own article someday.

The first example uses the standard op-amp oscillator circuit to generate a triangular waveform which is level-shifted and fed to a comparator (e.g. LM339) to give the PWM waveform.
Purchasing LEDs
LEDs are available all over the Internet. Recommending a single source or particular LEDs is hard as prices, projects, and the LEDs themselves may vary. If you are planning on starting an LED lighting project, it is best to do some research. For smaller applications, like a reading light, it may be more cost-effective to skip out on the top-of-the-line and buy a few more (relatively) cheaper LEDs. If you want to build a moonlight for your fish-tank, then you don’t need all those lumens blinding your fish!
The science of Electrocution 1
Several factors determine how dangerous electricity can be. Voltages, currents, resistances, and frequencies are the major factors that determine whether you will be hospitalized or just feel a little buzz. So consider all this the next time you plan on sticking your finger in an electrical outlet or straddling an electric fence.
Voltage doesn’t kill. Current kills.
Contrary to popular belief, you cannot feel high voltage directly and it will not kill you. Voltage is simply the amount of stored energy at a point in space. Current is the motion of that charge and can have lethal effects. As we will see later, there is a relationship between voltage and current that makes high voltage significant. This concept is best explained through the following analogy.

- In the first scenario, the piano is suspended above our stick figure with some amount of stored energy. Because the piano is suspended, it poses no danger to our stick figure.
- In the second scenario, the piano is released, and the stored energy is converted to motion. The piano is now potentially lethal.
Similarly, voltage is of no danger unless your body completes a circuit (if you are touching the ground) and a charge is able to flow through your body.
Effects of current on your body
There are several factors that influence current’s effect on your body. First of all, everyone has a unique chemistry so the effects are different for everyone. In fact, the small difference between a man’s body and a woman’s body cause significant variations. Secondly, the frequency of the current plays a critical role. The human body’s nervous system and muscles communicate using a frequency of 50-60hz making us extremely susceptible to current at this frequency. High frequencies and direct current are not as harmful.
The tabulated effects of current on the human body:
BODILY EFFECT DIRECT CURRENT (DC) 60 Hz AC 10 kHz AC
---------------------------------------------------------------
Slight sensation Men = 1.0 mA 0.4 mA 7 mA
felt at hand(s) Women = 0.6 mA 0.3 mA 5 mA
---------------------------------------------------------------
Threshold of Men = 5.2 mA 1.1 mA 12 mA
perception Women = 3.5 mA 0.7 mA 8 mA
---------------------------------------------------------------
Painful, but Men = 62 mA 9 mA 55 mA
voluntary muscle Women = 41 mA 6 mA 37 mA
control maintained
---------------------------------------------------------------
Painful, unable Men = 76 mA 16 mA 75 mA
to let go of wires Women = 51 mA 10.5 mA 50 mA
---------------------------------------------------------------
Severe pain, Men = 90 mA 23 mA 94 mA
difficulty Women = 60 mA 15 mA 63 mA
breathing
---------------------------------------------------------------
Possible heart Men = 500 mA 100 mA
fibrillation Women = 500 mA 100 mA
after 3 seconds
---------------------------------------------------------------
Ohm’s law (V = I*R)
Ohm’s law, voltage = current * resistance, is the deadly relationship between current and voltage. Basically, if you connect a charged source to ground, the current through you is going to be directly proportional to the sources voltage. Therefore, a high voltage differential causes high current. The amount of current is indirectly dependent on your resistance.
The human resistance factor
Unfortunately, the human body makes a horrible resistor. Because we are composed mostly of water inside, the majority of our resistance is in our skin. Personally, my hand-to-hand resistance is about 540 k-ohm. Wetting down my fingers reduces my skins resistance and drops this number down to around 60 k-ohm. This is why you never want to be wet around electricity. Nine times more current is able to flow through my wet skin at the same voltage!
Why birds can stand on power lines
On simple property of electricity holds it ground in the example. Current prefers the path of least resistance. It would rather flow through the wire than the bird, which has a relatively high resistance compared to a power line. However, a charge always wants to obtain and equilibrium. If an object connects a charged line to a source with less charge (say the ground), then this becomes the easiest path for the source to discharge itself.
How an electric fence works
While I am writing, I should dispel another rumor. Most people assume an electric fence has current flowing from one end of the fence to the other when in fact it is charged uniformly from both ends. There is no significant current flow until you complete a circuit to the ground. In fact, the unit that powers an electric fence is sold as a ‘fence charger.’
This is a common misconception because common electric fences have a pulsating voltage. There is in fact a small current flow as the fence is charged and discharged, but the flow is not from one end of the fence to the other. It simply in and out of the fence.
Powering LEDs costs mere pennies 33
Lately the hoopla concerning LED lighting has been overwhelming. Everyone claims this costs mere pennies to power. I decided to put a new twist on a classic science experiment to prove that LEDs do cost pennies to power. Literally.
Creating a battery from pennies
In order to turn pennies into batteries, another electrode and an electrolyte are needed. In this case, dimes (zinc) are used as the positive electrodes and salt water is used an electrolyte. Copper wire, galvanized nails, and lemon juice are also popular and cheaper solutions. Such a battery produces a differential of about 0.5 volts.
Finding ample power for an LED
Unfortunately, this battery is not enough to light an LED. In order to string eight of these cells in series, an ice cube tray is used. Metal paperclips hang the pennies and dimes into the electrolyte banks. Because the paperclips are conductive, the eight cells are automatically connected in series forming a more powerful battery. This provides a differential of about two volts.
As you may notice, 0.5 volts * 8 != 2 volts. Not all of the banks produced a reliable voltage. In fact, one bank seemed to be working against me.
Lighting a LED with pennies
Generally, LEDs require a resistor to prevent excessive current flow from blowing them out. This project does not require a resistor because the battery simply cannot provide that amount of current.
Connecting the short end of the LED to the penny and the long end to the dime lights up the LED! Everything works as planned. The penny batteries provide about 110 micro-amps of current in series. At two volts, this is only about 220 micro-watts of power!
It does in fact ‘cost’ pennies to power an LED.
Project Photo Gallery
Sound card based signal generators 4
Previously, E-DSP visited the possibility of using your sound card as a signal/function generator. I was curious about the results, but did not have a Windows machine close by to test it. After some searching, I found a Linux alternative and was able to test the limitations of my Sound Blaster Live!
SigGEN: A Linux signal generator

SigGEN is a fairly advanced signal generator designed specifically for Linux. It is able to generate sine, cosine, triangle, sawtooth, square, and pulse waves as well as white noise and frequency sweeps. It also supports separate waves on each stereo channel and setting phase differences between them.
Digital Signal Generator (Windows)

I was also able to find a Windows-based solution more advanced than E-DSP’s. It is able to generate sine, square, and triangle waves as well as chirp signals and noise.
Reproduced wave accuracy
Modern computers have no problem accurately calculating a reproducing small signals. Therefore, any limitations will lie in the sound cards specs. Most modern sound cards have a 16-bit digital to analog converter (DAC), and 24-bit DACs are becoming more popular. Even 16 bits of accuracy is far better than the 10 bits common on most embedded microcontrollers.
The major limiting factor in wave reproduction is the sound cards sampling frequency. It is limited to 48kHz. Hence, any frequencies near or above 24kHz are extremely hard (if not impossible) to reproduce without additional hardware. This limit is rather low and limits the generator usefulness as a high frequency signal generator.
Maximum deliverable voltage

I am sure that different sound cards are capable of delivering different voltages. My Sound Blaster Live! card was able to deliver four volts as seen above.
Maximum current and power
A sound card is also limited in the amount of power it can deliver. Once a voltage source reaches its power limit, it begins acting as a constant current source. It simply delivers less voltage to compensate for the limited current.
In order to test the sound card’s limit, a potentiometer is connected between the generated signal and ground. The resistance is then decreased until the current peaks and the voltage starts to decrease.

Once we find the point of maximum power, the potentiometer’s resistance is measured, and Ohm’s Law is used to find the current delivered. In this case, the resistance is 24.8K ohms. V = I*R tells us 0.16mA is being delivered. P = V*I = 0.6mW maximum power.
This is not a lot of current or power. This is why E-DSP reccommends an amplifier.
Project photo gallery
DIY Lie detectors
Makezine recently posted a diy lie detector kit that uses your skin resistance (aka sweat) to detect a lie. The kit is well explained and consists of two probes you place on your palm with a red/green led readout.
Multimeter based feedback
This is all well and good, but sometimes a little more feedback is a bit more intuitive. We are trying to learn here.
Some time ago, Jason Bradbury created his own lie detector using only a resistor, a transistor, an led, and a multimeter. The led lights up if you are lying, but the multimeter provides more precise feedback of the skin’s resistance.
If you are really desperate, you can just clip the leads of your multimeter straight to your subjects palm. The ‘scary’ device may cause them to sweat and ruin the experiment, though. Just don’t tell your girlfriend you will shock her if she does not love you.
Finger straps and the LEGO RCX
The galvanic skin response sensor uses a LEGO RCX brick to detect lies and also has numeric feedback. The finger straps are the best part of this project. Your subject will know you mean business when you clip these puppies to your multimeter.












































