SparkFun Forums 

Where electronics enthusiasts find answers.

General project discussion / help
Did you make a robotic coffee pot which implements HTCPCP and decafs unauthorized users? Show it off here!
By LH18
#200077
Hello, I am at a beginner level with circuits and have a basic question I'm having trouble finding an answer to related to a project I'm working on.

I'm making a very small sculptural object that is basically a Lightbox that I want to turn on when tilted in one direction. Right now I have an ATTINY85 powered by a 3v cell battery. The ATTINY powers a tilt sensor/switch from one pin and takes a reading from another pin. A third pin is connected to an NPN transistor. The transistor switches a 9V circuit with 16 LEDs in series/parallel (led -> led -> 150 ohm resistor). Currently this all works correctly. However, the project area is very small and I'd like to reduce the space required by components.

I'm wondering if the ATTINY is actually necessary or if I could achieve the same result with something like a voltage divider. I've watched and read a number of tutorials on transistors, circuits in general, and resistors as voltage dividers, but can't seem to figure it out. I've read that voltage dividers should not be used to power a load, but what I'm not sure is whether this particular configuration would cause a problem. Two photo links below show the current setup with the ATTINY and a potential new version. Any feedback/suggestions for how to safely and reliably remove the micro controller form the equation would be very much appreciated.

Components in V1:
3v cell battery
ATTINY 85
NPN 2N2222 A transistor
Base resistor 3.3k ohm
tilt sensor/switch (https://www.amazon.com/gp/product/B00R2 ... UTF8&psc=1)
resistor on tilt sensor/switch 10k ohm
16 LEDs 20 mA 3.3v, total 160mA
9v (3 x 3v cell batteries in series)

Sketches of circuits:
https://www.flickr.com/photos/156061440 ... ed-public/
https://www.flickr.com/photos/156061440 ... ed-public/
By LH18
#200111
Hi DanV,

Thanks for the suggestion and response, I appreciate it. Originally, I was planning to just use the tilt switch and batteries, but then I noticed that the original switch I had was only rated for 20 mA (https://tinkersphere.com/sensors/750-tilt-switch.html) and my LED array uses 160 mA. I realize the switch I linked to in my post is supposedly higher (.3 A according to the listing), but since I haven't been able to locate a data sheet I was a little skeptical. Most of the switches I've seen have much lower ratings, in the 5-20 mA range (for example: https://cdn-learn.adafruit.com/download ... sensor.pdf). I've also read elsewhere with other tilt switches that they aren't intended as "load switches."

So, I guess part two of the question is what would happen to the tilt switch if it were exposed to a higher current than it should be? Is there a risk of heat/fire? Or maybe there is something about the power rating that I'm not understanding properly?

Thanks again!
By jremington
#200115
You do want to use a transistor to increase the effective current handled by the switch. The 2N2222 is good to about 800 mA, if it is saturated.

I've attached a simple circuit diagram to show how to do that, assuming that the LED array is current limited to 160 mA, as you stated. If the LED supply is 12V, then the switch (and transistor base) current will be about 12 mA, which should be enough to saturate the transistor at 160 mA.

(Note: LTSpice, used for making the schematic, lacks a standard switch symbol).
switch.png
You do not have the required permissions to view the files attached to this post.
By LH18
#200443
Thank you jremington, this is helpful.

Also thank you DanV. I ended up just using the tilt switch without a transistor because I put the project together before I saw the last response. So far it is working well.