# Touch switch with two outputs - only driving LEDs

#### HappyPixie

Joined Aug 4, 2019
13
OK, so I’m a woodturner. I dabbled with wires 45 years ago when transistors were available individually and microchip ID numbers had just two digits.

I’ve turned a wood project which needs to incorporate a circuit with two outputs running from the same CR2032 button cell. One output is to three orange LEDs and the other will be to two white LEDs. I only have a small circular cavity 50mm diameter and 6mm deep to put the battery and electronics in. I was going to just use a SPDT, centre-off switch to control the outputs but I’d like to use a more elegant solution. Ideally there would be three touch panels instead. Touch one and output one lights up, touch the second and the first output switches off and the second output lights up. Touch the third touch panel for ‘off’, irrespective of which circuit is live. I’d be just as happy with a single touch pad that cycles between: only output one on; only output two on; and, all outputs off. I’m interested in the panels which are just a single piece of metal rather than the type where the finger makes contact between two pieces of metal. I plan on using an old brass watch cog as the touch panel(s).

Although that’s the plan, I’ve not rigged up a test to see how long the 3v button cell will keep the LEDs lit before expiring. That may be a flaw, but I plan on having the battery cradle easily accessible for changing the battery.

I’ve looked through quite a few of the ‘touch switch’ projects in the AAC history but they seem to be for higher voltages or for only one circuit. I’ve looked through eBay and seen little boxes for very little money suitable for single circuits, but it’s not obvious how they can be adapted to my multi-output requirements.

The first question is, could my project be achieved within such a tiny footprint? I will probably not use a circuit board but connect the components with bare wires and encase the whole thing in epoxy as a kind of all-round insulation. The second question is whether anyone is interested in this particular (and rather specific) challenge?

I’ve already bought the semi-circular battery cradle, the LEDs and some resistors for them and the SPDT switch. Beyond that, I’m open to suggestions – even buying different components.

Any thoughts? Any questions? Any interest?

Steve (just north of London, UK)

#### dl324

Joined Mar 30, 2015
12,677
Welcome to AAC!
I’ve turned a wood project which needs to incorporate a circuit with two outputs running from the same CR2032 button cell. One output is to three orange LEDs and the other will be to two white LEDs. I only have a small circular cavity 50mm diameter and 6mm deep to put the battery and electronics in.
Your available space probably means that you need to go with surface mount components. Are you able to work with them?

What is the forward voltage of the white LEDs? Whatever it is, you're not going to get full brightness from them because typical voltages are in the 3-5V range.

Sometimes LEDs are connected directly across CR2032 batteries; without current limiting resistors.

Your choice of voltage also limits any logic IC's you can use.

#### ci139

Joined Jul 11, 2016
1,696
https://www.batteryequivalents.com/...2-batteries-equivalents-and-replacements.html
↑quote from↑ : "Note: Common LiR2032 battery is 3.6 V battery, with typical capacity in 50-70 mAh range. Their capacity is obviously lower than CR2032's average 220 mAh capacity, but LiR2032 batteries can be recharged 500+ times."

note. The mA·h rating is usually the "usable" capacity not the top to fully discharged one

depending on type -- the LED becomes visible(luminating) starting at 270 to 540 µA some perhaps higgher . . . but @ the 1mA IF they usually are fairly well visible at near distance then they ?step brighter? at 4mA , 10mA , 14mA and 21mA . . . the outdoor night garden lights are set to 2mA IF (just enough to lit your pathway in the dark) and they use 100mA·h NiMH-s

so brand new 220mAh CR2032 will ideally keep the 2mA IF LED running about 110h = 4 and a half days
while the re-chargeable LiR2032 is usable some 60mAh/2mA=30h = 1 and 1 4-th of a day
if you can do with lesser intensity the working hours double
if you need more light power you'll have to swap the cell-coins more frequently

ideally -- some MCU-s have output current ratings that allow to PWM the LED-s stright from MCU pins . . .

the wires actually take a lot of space while the PCB-s can be made more compact . . .
________

lf you have not selected your switch yet - there's one option

Last edited:

#### HappyPixie

Joined Aug 4, 2019
13
Many thanks to Dennis (dl324) and ci139. I'm guessing the surface-mounted components are those tiny crumbs that I see on PCBs in computers, etc.? I don't have the facility to create a PCB although I'm sure there's an online supplier somewhere. I suspect this will have to rely on discrete components since it's a one-off project (probably).

I was expecting the item to be lit only while the user was playing with it or viewing it - it'll be a wooden shape with lights in. I expected it would be switched off after an hour (or thereabouts) and left off until the next time it is played with.

Sadly, I bought the LEDs four years ago so I don't have the forward voltage details anymore. I guess I'll just buy more depending on the requirement of any circuit that is proposed. They're cheap.

The suggested switch is intriguing but the reason I want to use a cog (or three) is to cover up a mistake I made. Woodturning errors allow for these intriguing design adjustments The tail of the suggested switch would be too large to hide unless I carve significant lumps out of the finished wood shape.

Thanks again and I'll wait to see if there are any more suggestions before I resort to my simplistic SPDT switch fallback option.

Regards

Steve

#### iimagine

Joined Dec 20, 2010
483
I’d be just as happy with a single touch pad that cycles between: only output one on
You could use a decade counter IC like the CD4017 rated at 3v-18V like this:

#### ci139

Joined Jul 11, 2016
1,696
There is no musts , you can always use any design consisting of any components
(( also , there are people making custom PCB-s for a single pcs. quantity ))
I don't have the forward voltage details anymore
takes a multimeter , set of resistors or 0.5W 1W potentiometer and 9V 6LF22 to determine VF (the voltage drop) at some IF (forward current)
usually the small power colored leds have voltage drop (for thenominal IF ?? 20mA) in the range of 1.6 to 2.4V also have logarithmic dependency on current (some white and most of the blue LED-s have V.nom. a bit above 3V)
‘touch switch’ projects in the AAC history but they seem to be for higher voltages
i've built the 1.5V one over three decades ago (but it was on soviet parts . . .) (PS! i was a beginner then it's a bad design . . . (but it worked) . . . the R1 & R2 simulate the ohmic contact pads)

there's a bjt 1

it can be made also from LM293 or other low voltage comparator ??? Selecting the Right ComparatorMAX9100
smth. like ? this

Last edited:

#### djsfantasi

Joined Apr 11, 2010
7,551
Someone is bound to say it and I believe it’s my turn.

Can you code?

A small microprocessor can do everything you want. Something like an ATTiny25/45 and either a spare Arduinos Uno ($3.50 plus a pack of jumpers and a breadboard) or a stand-alone programmer* ($17) is all that is needed to program the chip.

The chip size is 0.25”x0.375”x0.4” and available in TH format. It has a built-in clock, so you can time the events. And one analog pin can be programmed as a touch sensor, leaving several for the LEDs.

#### ci139

Joined Jul 11, 2016
1,696
even without input noise digital filtering it'll be quite a lot of messy code (← Tinkercad touch button sim)

#### HappyPixie

Joined Aug 4, 2019
13
This is certainly moving way beyond my normal comfort zone. The last coding I did was writing simple programmes on my Psion Organiser about 30 years ago. My family bought me a Raspberry Pi 3 B+ last year but I've not really got into it, yet.

Although I followed the TinkerCAD link and was excited by how similar the project appeared to mine, I think learning coding via the Pi onto an ATTiny would be beyond my patience. I'm familiar with my clunky soldering iron.

I looked at ci139's YouTube video and it's close but the LEDs only stay lit while the finger is on the metal (or two metal) strips. I need something that would switch on with a touch and stay on until the next touch that switches it off - either using the same touch pad or a separate one.

I'm intrigued by iimagine's decade counter. Would that require lots of other components and a complex circuit?

Another point, I hadn't considered is whether the three orange LEDs should be in series or parallel. The same point for the two white LEDs. Would this affect how long the LEDs last or how bright they shine?

Regards

Steve

#### djsfantasi

Joined Apr 11, 2010
7,551
even without input noise digital filtering it'll be quite a lot of messy code (← Tinkercad touch button sim)
I don’t understand why there’s a lot of messy code. With an ATTiny45 and the Arduino IDE, it’s just a little more than this...
Code:
CapacitiveSensor   cs_2_4 = CapacitiveSensor(2,4); // 1M resistor between pins 2 & 4, pin 4 is sensor pin, add a wire and or foil

int in = 2;
int out = 4;
int state = HIGH;
int r;
int p = LOW;
long time = 0;
long debounce = 200;
void setup()
{
pinMode(4, INPUT);
pinMode(8, OUTPUT);
}
void loop()
{
if (r == HIGH && p == LOW && millis() - time > debounce) {
if (state == HIGH)
state = LOW;
else
state = HIGH;
time = millis();
}
digitalWrite(8, state);
p = r;
}

#### iimagine

Joined Dec 20, 2010
483
I need something that would switch on with a touch and stay on until the next touch that switches it off - either using the same touch pad or a separate one.
Since you are only required 2 outputs, you can do something like this:

or for 2 buttons:

However, you are going to need to find mosfets that will work with 3V

or for cd4017 driving multiple leds per output, see this -> https://forum.allaboutcircuits.com/...ne-at-a-time-with-a-push-button.162160/unread

#### ci139

Joined Jul 11, 2016
1,696
Ideally there would be three touch panels instead. Touch one and output one lights up, touch the second and the first output switches off and the second output lights up. Touch the third touch panel for ‘off’,
if you want tho optimize the buttons you have several more options --e.g.-- if a LED(-s array) is ON and a button for that led is tapped it turns the LED OFF if another is tapped the other 1 lits etc.

? but i understood it'll be a toy for a kid ? (also to account with control design ...)
I was expecting the item to be lit only while the user was playing with it or viewing it
___

about Lo-3shld MOSFETS . . .

i think the BSD223P might suit because of 0.6V V.th (similar to bipolar if required to mix with) and High R.ds.on (might reduce the need of limiting resistors)

Q.C.

Last edited:

#### HappyPixie

Joined Aug 4, 2019
13
Thanks iimagine. Your single switch circuit looks exactly like my planned project with the sole exception that the physical switch seems to require contact to be made between two points. In other words I’d have two pieces of conductor on the outside of my project and a fingertip covers both and provides the contact. I can live with that.

Thanks to ci139 for the MOSFET suggestion. If my searches are correct, this is a surface mounted thing and I’m also confused by the six legs since the circuit only shows three being used. Is it practical to hand solder wires onto these tiny little things or am I likely to melt the chip?

Further searching gave me this thread:

… where they suggested MOSFET 3055L. I can find these on eBay with long legs (suitable for ham-fisted amateurs, like me), but they quote 60V and between 3A-12A. Is this what they need to drive them? If so there must be a lightweight version if the suggestion in the thread is to be believed.

Finally, when I said “play” it’s because this is a woodturned project which is somewhere between sculpture and executive toy. If it works well, I may make a few more variants on the theme, so the circuit might get used more than once.

Many thanks to all

Steve

#### iimagine

Joined Dec 20, 2010
483
… where they suggested MOSFET 3055L

#### AnalogKid

Joined Aug 1, 2013
9,042
You could use a decade counter IC like the CD4017 rated at 3v-18V like this:
If you tie the Q4 output to the Reset input, with no LED connected to Q0, you don't need any of the diodes. Note that a 4017 can source *very little* current when running on 3 V, not enough for a good result when driving three LEDs in parallel.

ak

Last edited:

#### AnalogKid

Joined Aug 1, 2013
9,042
Another point, I hadn't considered is whether the three orange LEDs should be in series or parallel.
With such a low battery voltage, all LEDs must be in parallel, each with a separate current limiting resistor.
The same point for the two white LEDs.
Depends on the LED. Some white LEDs will not run (or just barely come on) on 3 V.
Would this affect how long the LEDs last or how bright they shine?
Yes.If you run 10 mA through the LEDs to get reasonable brightness, then they are drawing either 30 mA or 20 mA continuously when on. Divide the battery capacity (in mA-h) to get an approximate run time. Note that toward the end of that time things will be pretty dim.

ak

#### AnalogKid

Joined Aug 1, 2013
9,042
You can do this with NAND gates as flipflops, but nothing beats the 4017 circuit for simplicity - when expanded with LED driver transistors. The same function in an 8-pin uC would be smaller but still have the critical problem - battery voltage. Do you have a part number or datasheet for the white LEDs you are considering?

ak

#### djsfantasi

Joined Apr 11, 2010
7,551
For what you’re doing, hand soldering SMT (surface mount) devices is not impossible. First, you can buy adapters to which you solder the SMT device, and it brings out the connections to a larger area or to hand wire it. Ive included a link to one for SMT devices in the SOT23 package. Secondly, buy a bunch of inexpensive SMT devices (a bag’o resistors) and practice hand soldering. You just need a fine solder wire or purchase solder paste.

Can you code? Because of the options, a small microprocessor and programmer can let you change the toy’s patterns at will.

#### AnalogKid

Joined Aug 1, 2013
9,042
Here is a first-pass at the guts of the 4017 circuit. Because the 4017 will try to respond to each individual cycle of the noise burst that can come from a touch pad, the input needs a filter/conditioner to turn each touch into a single clock event. C1 is a decoupling cap for U1; unless the battery is right next to the chip, the chip still needs a cap.

Note - there is no need for 1% tolerance resistors; those are the closest value in my design library.

ak

#### HappyPixie

Joined Aug 4, 2019
13
Ah, yes, iimagine. It seems the PMV28 was proposed in the end. Would that do the job in your circuit?

I appreciate the link to the adaptor board for the chips, djsfantasi. That looks a workable solution. I have some thin solder wire so I’ll have a practice. Do the chips get damaged when heated, because my soldering iron tip isn’t exactly dainty.

I don’t think I’ll go the coding route, though. Although I can transcribe your suggested code, I don’t know how to get the code into the chip (connectors, adaptors, intermediary boards, shovel, etc.). I’d have to learn how to do all that first.

Welcome to the party, AnalogKid! Your circuit suggestion is the closest so far to what I’m seeking and – with all the descriptions of the components – the easiest for me to order parts for. I’m seeing a wide variety of 2N7002 variants on eBay with different Amps and Watt specifications (they all seem to be 60V). Is there a preferred choice? I suspect I’ll have to source fresh LEDs, too, since I can’t remember the spec on the ones I’ve got. The three orange ones need to be the 5mm×7mm×2mm ones and the two white ones can be any kind because they won’t actually be seen. I see references to Mouser and other suppliers. Perhaps it's time for me to set up an account. Any recommendations for a UK-based customer?

AnalogKid. Although your comment “the input needs a filter/conditioner” may bring up a mental image of the precise circuit to those who normally read this forum, the only conditioner I’m familiar with was back in the days I had hair. Could you suggest something for that, too, please?

Thanks again to all the contributors.

Steve