Tilt Switch and Transistor without Microcontroller

General project discussion / help
Did you make a robotic coffee pot which implements HTCPCP and decafs unauthorized users? Show it off here!

Moderator: phalanx

Post Reply
LH18
Posts: 5
Joined: Wed Aug 15, 2018 4:08 pm

Tilt Switch and Transistor without Microcontroller

Post by LH18 » Sat Aug 18, 2018 5:57 pm

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/

User avatar
DanV
Posts: 393
Joined: Sat Apr 25, 2015 9:29 am

Re: Tilt Switch and Transistor without Microcontroller

Post by DanV » Mon Aug 20, 2018 7:10 am

I think you should consider no transistor - just use 9V and tilt switch.

LH18
Posts: 5
Joined: Wed Aug 15, 2018 4:08 pm

Re: Tilt Switch and Transistor without Microcontroller

Post by LH18 » Wed Aug 22, 2018 1:28 pm

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!

User avatar
DanV
Posts: 393
Joined: Sat Apr 25, 2015 9:29 am

Re: Tilt Switch and Transistor without Microcontroller

Post by DanV » Wed Aug 22, 2018 2:33 pm

Not fire - it will weld the ball inside the switch to the internal contacts and will not work well afterwards (won't turn off).

jremington
Support Volunteer
Posts: 2327
Joined: Fri Jun 15, 2007 9:41 pm
Location: Eugene, Or

Re: Tilt Switch and Transistor without Microcontroller

Post by jremington » Wed Aug 22, 2018 7:26 pm

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
switch.png (5.19 KiB) Viewed 268 times

LH18
Posts: 5
Joined: Wed Aug 15, 2018 4:08 pm

Re: Tilt Switch and Transistor without Microcontroller

Post by LH18 » Sun Sep 23, 2018 1:29 pm

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.

Post Reply