The declared purpose for this project is to detect the presence of a person, in a relatively tight area, and switch the light on and off.
Because I didn’t want to use a full Arduino (i.e. whatever 16MHz ATmega328P) I switched for an improvised Arduino.
Actually it is an ATtiny45 AVR controller intended for some other application. I just fitted it in to match my purpose.
As you may know, out there is an extension for some ATtiny controllers to behave as Arduino, of course a tiny one . Take a look here: https://code.google.com/p/arduino-tiny/ to figure out whether this is interesting for you.
Here is the schematic in pdf format.
Some explanation might help to have an idea of how this is actually working.
- The 24V relay: this is one that I had had the intention to use for this project, because the light is powered by 24V (a LED fixture). You can use some other relay but have to adapt the schematics.
- The PTN78060W is a 3 Amp Wide input – Adjustable Switching Regulator. I got a bunch of them and now I use them everywhere [Note 2]. As you can see, from the data sheet, there is, indeed, a wide range of values for input voltage, from 7V to 36V, and the output voltage goes from 2.5V up to 12.6V. What is really amazing is the efficiency of 93%, that means it works cold. The output voltage is adjustable by one resistor (see the values in the table at the end of data sheet).
- Now we get closer to the “core” of this project.
- The first part is LV-MaxSonar®-EZ0™ High Performance Sonar Range Finder. It detects objects from 0-inches to 254-inches (6.45-meters) and provides sonar range information from 6-inches out to 254-inches with 1-inch resolution. Objects from 0- inches to 6-inches typically range as 6- inches. The interface output formats included are pulse width output, analog voltage output, and serial digital output. I use here the pulse width output. It outputs a pulse width representation of range. The distance can be calculated using the scale factor of 147μs per inch. That means for 6 inches distance the width of pulse is 6*147 = 882μs and for 40 inches the width is 40*147 = 5880μs or 5.88ms.
- The second part is the AVR controller ATtiny45. This behaves as Arduino, a tiny one – of course, with only 6 pins (plus two for Vcc and GND). This might be enough for some applications. As specified before, you can install the tiny core extension for Arduino IDE. To figure out what’s about you can take a look at Arduino Forum and this topic might be a good start: http://forum.arduino.cc/index.php?topic=173408.30.
Some words about the code
Here is the file with the code (pdf format).
[To be continued …]
I usually use what I have at hand and match what I have to improvise a solution for my purpose. This is the reason for some mixtum-compositum you can find weird or not so usual. The amount of money spent is almost zero. Indeed I have a pile of electronic stuff gathered during long years…
I have a couple of applications for these nice little guys.
- Tiny AVR Programmer (PGM-11801) (sparkfun.com)
- An Arduino With Better Speech Recognition Than Siri (hackaday.com)
- My first Arduino Challenge (qualityideasguy.com)
- This shivering bracelet investigates time (atmelcorporation.wordpress.com)
- Atmel-Arduino controls this beer brewing machine (atmelcorporation.wordpress.com)
- Designing the perfect keyboard with an Arduino Micro (atmelcorporation.wordpress.com)
- Driving social change with Atmel and Arduino (virtual-strategy.com)
- Top Ten Arduino Posts of 2013! #arduino #AdafruitTopTen (adafruit.com)
- More Humane Moisture sensor (instructables.com)
- The smallest Arduino ever OLIMEXINO-85S is just 16.9 x 12.7 mm (0.67×0.5″) ! (olimex.wordpress.com)