The Guardian-Angel-o-Meter

by Jocobs in Circuits > Electronics

3386 Views, 19 Favorites, 0 Comments

The Guardian-Angel-o-Meter

Title.jpg

A Short Background Story

My mother has been going through a rough time health wise recently. Being her son I am used to her caring for me not the other way around. So I did what I can do best, I built something. I present to you the "Guardian-Angel-o-Meter". A device that uses innovativ technology to sense the presence of a guardian angel. Every time an Angel is detected the red LED blinks. One blink per angel, even if he/she stays around, the device will only blink upon a new arrival (using Angel-edge-detection). So if u ever find yourself in a spot where you feel lost or even hopeless, simply flick a switch and you'll see there's lot's of angels looking after you.

Enough of the advertising! Of course I did not invent something that proves the existance of angels or even detects anything really. I simply built a little device that randomly blinks ever so often. However I belive that imagination is a very powerfull tool. The idea of something being around that protects us is, quite frankly, very calming. We could probably start a very long discussion about this topic but let's dive right into the building process and I'll show you how you can build your very own GA-o-meter.

Gathering the Parts

As I already mentioned in the introduction, the guardian-angel-o-meter simply lights up an LED randomly in between a defined time interval. I am using an ATTINY 45 for this but you could really use any microcontroller that has a small enough footprint.

In addition you'll need a small button cell battery holder, a switch, a red LED (or whatever color you prefer) and a current limiting resistor for the LED. You will also need something to mount it all on. I used a small piece of perf board and covered to bottom with a piece of plywood, but more on that later.

Programming the Attiny

The heart of the circuit is the attiny45. It's fairly cheap and can be easily picked up on ebay or amazon. As I already said above, u can use any microcontroller you want for this but since I still had a couple of the tinys at home I went for this route. I used an Arduino UNO as an isp to programm the attiny. I will not go into detail about how this is acomplished, since there are already quite a few great tutorials about this out there. One of which is this. I built myself a small shield a couple fo years back which makes programming just more convenient but you could totally get away with a breadboard and a couple of jumpers

The Code:

The code of this program is very simple. The basic idea is that a random number, between two boundaries, will be calculated. This number defines the time the led is turned off. Then it’s switched on for a specific amount of time and switched off for a random duration again. Since the random() function, provided by the Arduino ide, simply cycles through a very long sequence of different numbers (making it seem random, hence the name), the blinking pattern after each reboot would always be the same. To prevent that the function randomSeed() can be used. It reads the value on any analog input and uses it to set the starting point of the sequence. Since there will always be noise and electromagnetic interference around, it is highly unlikely that the reading on this pin will very be the same two times in a row.


#define LED_PIN 0
#define INPUT_PIN 1
#define TIME_ON 1000
#define LOWER_LIMIT 500
#define UPPER_LIMIT 30000

// --------------------------------------------------------------------------------------------------------------------------
long rand_off;

void setup()
{
randomSeed (analogRead (INPUT_PIN));
pinMode(LED_PIN, OUTPUT);
}

void loop()
{
rand_off = random (LOWER_LIMIT, UPPER_LIMIT);
digitalWrite(LED_PIN, LOW);
delay(rand_off);
digitalWrite(LED_PIN, HIGH);
delay(TIME_ON);
}

Join the Resistance!

This is actually the second version I am building of the GA-O-Meter. The one my mom has does not include any current limitation for the LED. It dawned on me only after I decided to write this 'ible that it shouldn't work the way I built it. Since the attiny's maximum output current is 40mA and the diode only lives up to 25 ish it should by now have fried the LED. I can only assume that either the tiny is not outputting as much current as stated or I got lucky with my LED. Anyhow I decided to be a good example and build it the correct way.

If you wish to fully understand the reasons for needing to limit the current, google is your friend. Ther's a ton of information about that already out there. In short though, the characteristic of a diode follows an exponential function. Meaning a small change in voltage represents a big change in current. In addition to that a diode has a positiv temperature coefficient. Meaning the higher the temperature gets the more current will flow through it. So if you simply attach the diode to a constant voltage source the current will keep rising (because the LED get's warmer and warmer) until it finally releases its magic white smoke (meaning it's dead). This is why LED's always need to be driven by a constant current source or at least need some sort of current limitation. The easiest way to acomplish this is by using a resistor. The idea is that by having a constant voltage the current through the resistor will be set according to Ohm's law (I=U/R). Firstly we will need to set a bias point for the LED (0,8 V should work). Since we know that the attiny will output a maximum of 3,3 V we can now calculate the voltage we want to drop on the resistor.

( oh how I wish instructables had LaTex support...)

Using Ohms law we can now caluclate the needed resistance. The current through the LED depends on the LED u're using. Usually 10 - 20 mA should be maximum thought.

Now before soldering everything together it is advisable to try the circuit and see if everything works fine. If it does, like it did in my case, move on.

Creating the Circuit

The circuit is quite simply. Take your time laying out the components in a way that is both pleasent to look at and also practical from a soldering point of view. Make sure pins that are supposed to be connected together aren't too far away from each other, that'll just make your life much simpler later on.

I opted for the following layout:

Soldering the circuit is pretty straight forward. Take your time, make sure there are no shorts and everything is well secured. I had to glue on the switch, because its legs were too thick for the perf board to fit. I am certainly not proud about the soldering job I did, but it works and no one’s ever going to see it!

Adding the Base

At this point the GA-o-Meter is working and ready for use. However, I decided to kick it up a notch and add a fine looking base to it. I used a small piece of plywood I had lying around.

In order for the perf board to sit flush with the wood I had to cut a recess. So I took out my chisel and carving knife and after 20 minutes or so it fit like a glove.

I used two component adhesive to secure the perf board to the wood and let it dry overnight. After it was completely cured all there was left to do was throw some protective oil or wax in my case on the wood and the GA-o-Meter was done.

The Final Result

So this is how you can build your very own Guardian-Angel-o-Meter. It is a very simple build and to some it may seem a little childish. But it serves perfectly as a gift to remind a special someone that they're never alone and that there are people, or maybe angels, looking after them, caring and thinking about them.