Summary of Programmable Lamp Dimmer using pic microcontoller
This article details a DIY programmable lamp dimmer, nicknamed "Sketch as Fuck Lamp Dimmer," using a PIC10F microcontroller. Unlike standard designs, its logic ground floats 5V below the mains hot wire, requiring isolation for programming. The project employs a unique low-power power supply that drops 120VAC to 5V using a resistor and zener diode rather than a transformer, emphasizing minimal component count and cost.
Parts used in the Programmable Lamp Dimmer:
- PIC10F Microcontroller
- Triac
- Zero detector circuit
- Timer circuit
- 22k Resistor
- Rectifier Diode
- Zener Diode
- Isolation Transformer
Also known as the “Sketch as Fuck Lamp Dimmer” per my friend Eric, the design originating from this application note in general has the usual lamp dimmer topology: a zero detector, a timer, and a triac. These three components implement phase cutting, specifically the triac performs phase cutting on AC current from mains supplied to a load. The first two components, the zero detector and timer, are both implemented in a microcontroller, the subject of the application note.

One consequence of this is that, while plugged into mains, the logic of this circuit cannot be connected to any logic that is grounded to the neutral of mains unless the signals have some isolation. For example, I couldn’t connect connect my PIC programmer to the circuit while the circuit was plugged into mains without something exploding! To get around this, I plugged my circuit into an isolation transformer prior to mains during the latter part of programming the circuit, after I had confirmed my circuit functioned correctly electrically. As discussed later, this design is necessary to achieve proper biasing in the circuit, and you can see this power supply in other circuits as well–for example the application note for another lamp dimmer from ST.
Amused by this application note, I decided to build my own programmable lamp dimmer circuit. There are a couple neat techniques I took to make this project, so I’ll go through them one by one.
Power Supply Component Sizing and Theory of Operation
The application note intends to point out the low power consumption of the PIC10F microcontroller. As an example, it suggests building a lamp dimmer whose logic power supply resembles a 5V linear zener regulator. The power supply schematic from Eagle is given below–the 5V and 0V nodes are the power supply for the microcontroller. pic of power supply caption: This regulator converts mains 120VAC to 5V; mains is plugged into the connection indicated, with hot connected to the upper wire and neutral the lower wire. Normally, a linear regulator is not appropriate for converting between such disparate voltages — 120V (rms) to 5V. The voltage change is implemented by dropping the difference in voltage across a resistor, the 22k resistor in this case. Really, the only advantages to this kind of circuit are the relatively low number of parts, the cheapness of those parts, and the small footprint of those parts. For example, a circuit of components of this size could be embedded in the plug of a lamp itself, perhaps as a feature or a prank.
To explain how this circuit works and how to size components, let me simplify it. First, let’s consider the AC input signal, which is a hot wire and a neutral wire whose voltages differ by a 120VAC sine wave. An oscilloscope reading I took of mains is shown below.rm.
However, since what we intend to be the 5V node of the power supply is connected to hot, let’s instead consider the relationship between hot and neutral with hot as our reference voltage. This is still a sine wave, we’re just using neutral as our fixed reference, as shown in the following plot, where neutral is blue and hot is red.

For more detail: Programmable Lamp Dimmer
-
What is the main topology of this lamp dimmer?
The design uses a zero detector, a timer, and a triac to implement phase cutting on AC current from the mains. -
How is the logic power supply configured differently from standard circuits?
The 5V node connects to the hot wire of the mains, while the 0V node is constructed 5 volts below that wire. -
Why must an isolation transformer be used during programming?
The logic cannot connect to neutral-grounded devices like a PIC programmer without isolation, or it could cause an explosion. -
What components replace a traditional linear regulator in this power supply?
The voltage drop from 120VAC to 5V is implemented across a 22k resistor instead of a standard linear regulator. -
What are the primary advantages of this specific power supply design?
The advantages include a relatively low number of parts, cheapness, and a small footprint suitable for embedding in a plug. -
Which microcontroller is the subject of the application note?
The PIC10F microcontroller is the subject, noted for its low power consumption.