I Designed a Custom PCB to Avoid Pressing a Button Three Times

birdculture1 pts0 comments

I Designed A Custom PCB To Avoid Pressing A Button Three Times :: The Tymscar BlogI Designed A Custom PCB To Avoid Pressing A Button Three Times<br>2026-07-25Oscar Molnar10 min read (1973 words)<br>#pcb<br>#electronics<br>#easyeda<br>#jlcpcb<br>#attiny85<br>#soldering<br>#home-assistant<br>#opensource-hardware It&rsquo;s hard for me to explain why, but ever since I can remember I hated sleeping in full darkness. Perhaps it&rsquo;s to do with where I was born, where even during the night I could see street lights. Maybe it has to do with me just being a big baby.<br>But because of also being a nerd I love to automate all sorts of things like this. I use Home Assistant to control basically everything smart around the house, and one of the automations I have is to turn on a dumb night light using a Zigbee wall plug. Basically when my phone goes into the sleep focus mode, it tells Home Assistant that, which in turn runs a few automations around the house, one being turning on this night light.<br>All great right? Well, not really.<br>The light that always starts too bright#<br>I have bought a cheap night light from the internet that has a button and a switch. The switch basically tells it if it should turn on automatically at night (no thank you, I want that control myself, so the switch is always off), and the button basically jumps between the intensity levels supported.<br>Well, here&rsquo;s the issue. First of all, it doesn&rsquo;t start on intensity 1. It starts at 3. Then you press once, goes to 4, then again, goes to 5, then yet again and it goes to 1. So every single night when I went to bed, I would have to press that button 3 times because otherwise the light was way too bright.<br>Opening it up#<br>I have opened the light to take a look inside, maybe I can gain some information about the chips used there, maybe there is a potentiometer that I can use. But no.

The chips didn&rsquo;t have their names visible.

Someone online mentioned that these lights all use the same ICs basically and there&rsquo;s this trick where if you hold down the switch button for like 10 seconds you set in the EEPROM the new default value (instead of 3). Not on mine. I have tried everything.<br>So I gave up and just bought a smart night light that I can adjust from Home Assistant, and my nights were perfect since. Thank you for reading. Tune in next time for when I buy the solution to my next problem!<br>Pressing the button with a chip#<br>Nope. I did what any normal person would do and went down a rabbit hole of understanding how the circuit worked. In reality it wasn&rsquo;t anything super complicated, and I realised that my actual best bet at solving this would be a microcontroller that could just press the button for me so to say.<br>I had a few in mind, some that were in the room with me such as a Wemos D1 Mini (the ESP8266 one) and a Raspberry Pi Zero, but they all had some issues. The night light has no transformer in it, it drops the mains voltage with a capacitor instead, and that kind of supply can only give you a few milliamps. An ESP8266 wants hundreds of milliamps the moment it boots and turns its radio on, and the Pi Zero is a whole Linux computer that needs to boot an operating system before it can do anything at all, so both of them would have needed their own power supply, or a big reservoir capacitor and extra circuitry to survive the boot spike. Neither of those is &ldquo;solder three wires and be done&rdquo;.<br>So I decided upon using the ATtiny85. The reason was that this is a super well known chip, from the same AVR family the classic Arduinos use, so you can write the code in the Arduino IDE exactly like you would for an Arduino. And it uses basically 0 power. It&rsquo;s so low it&rsquo;s hard to even analogize, but I&rsquo;ll give it a go: running at 1 MHz it pulls less than a milliamp, and once it goes to sleep it drops to microamps, which is about what a quartz watch uses to keep ticking. The LED in the night light uses thousands of times more than that.<br>Now the issue is that I can&rsquo;t just hook this up to power, ground, and the button and be done with it. I also need:<br>An HT7333 voltage regulator , because the rail inside the light sits at 8.3 V and the ATtiny wants 3.3 V.<br>A 2N3904 transistor , which is the part that actually presses the button. It shorts the button&rsquo;s signal leg to ground, exactly like my finger does.<br>A 1 kΩ resistor between the chip and the transistor, so the chip only ever drives a tiny current into it.<br>A 10 kΩ resistor to hold the transistor off while everything powers up, otherwise you get a stray press at boot and the light jumps to a random brightness.<br>Three small capacitors , which smooth out the power going into the regulator and the chip.<br>A 3 pin header for the only three wires that leave the board: power, ground, and the wire that goes to the button.<br>At the end as you can see there&rsquo;s a ton of stuff, so I had this brilliant idea of spending even more time and money and creating a PCB for it? Why? Well, cause it would be...

button rsquo light night three basically

Related Articles