Page 1 of 1

Tilt Switch and Transistor without Microcontroller

Posted: Sat Aug 18, 2018 5:57 pm
by LH18
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/

Re: Tilt Switch and Transistor without Microcontroller

Posted: Mon Aug 20, 2018 7:10 am
by DanV
I think you should consider no transistor - just use 9V and tilt switch.

Re: Tilt Switch and Transistor without Microcontroller

Posted: Wed Aug 22, 2018 1:28 pm
by LH18
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!

Re: Tilt Switch and Transistor without Microcontroller

Posted: Wed Aug 22, 2018 2:33 pm
by DanV
Not fire - it will weld the ball inside the switch to the internal contacts and will not work well afterwards (won't turn off).

Re: Tilt Switch and Transistor without Microcontroller

Posted: Wed Aug 22, 2018 7:26 pm
by jremington
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

Re: Tilt Switch and Transistor without Microcontroller

Posted: Sun Sep 23, 2018 1:29 pm
by LH18
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.