Build it step by step
0 of 6 doneWire one strip
Drive the warm strip with its MOSFET, gate resistor and pull-down.
Add the second strip
Repeat for the cool strip on D6.
Add the knobs
Wire both potentiometers.
Test the mix
Turn the colour knob from warm to cool at a fixed brightness.
Compare the light
Use a phone colour-temperature app to check the range.
Mount
Fix the strips side by side on an aluminium channel with a diffuser.
How do you build a warm-to-cool desk lamp?
Two LED strips, warm and cool white, mix to any colour temperature with one knob and brightness with another. You need Arduino Nano, MOSFET IRLZ44N × 2, 12 V LED strip warm white (5 m, 2835), Potentiometer 10 kΩ × 2, 12 V 2 A DC adapter, Resistor 220 Ω × 2 and Resistor 10 kΩ × 2. It takes 6 steps and about 120 minutes.
- Level
- Intermediate
- Time
- About 120 min
- Parts
- 7
Parts list
- Development BoardsBuyArduino Nano × 1
- SemiconductorsBuyMOSFET IRLZ44N × 2
- OptoelectronicsBuy
- PassivesBuy
- PowerBuy
- PassivesBuyResistor 220 Ω × 2
- PassivesBuyResistor 10 kΩ × 2
Tick what you already own. It saves to My Garage, so “Build with what I have” knows.
Wiring
| From | To | Why |
|---|---|---|
| 12 V adapter + | Both strips' + wire and Nano VIN | 12 V supply |
| 12 V adapter - | MOSFET sources and Nano GND | Common ground |
| Warm strip - | MOSFET 1 drain | Switched side |
| Cool strip - | MOSFET 2 drain | Switched side |
| Nano D5 | 220 Ω resistor then MOSFET 1 gate, 10 kΩ gate to GND | Warm PWM |
| Nano D6 | 220 Ω resistor then MOSFET 2 gate, 10 kΩ gate to GND | Cool PWM |
| Potentiometer A outer pins | Nano 5V and GND, wiper to A0 | Colour temperature |
| Potentiometer B outer pins | Nano 5V and GND, wiper to A1 | Brightness |
Code
Arduino IDE, board "Arduino Nano" (processor ATmega328P, or ATmega328P (Old Bootloader) for clones). No libraries needed. Cut each strip to 0.5 m to 1 m at the marked cut lines, one warm white and one cool white, so the two together draw well under the adapter's 2 A. Feeding the Nano from VIN with 12 V works but its regulator gets warm; for a long-running lamp use an LM2596 module set to 5.0 V into the Nano's 5V pin. The default PWM is about 490 Hz and may show flicker on a phone camera.
Runs on a virtual Arduino Nano in your browser, with sliders for the sensors. Happy with it? Verify and upload to your real board from the same page (Chrome or Edge on a computer).
const byte WARM = 5, COOL = 6;
const byte KNOB_COLOUR = A0, KNOB_BRIGHT = A1;
void setup() {
pinMode(WARM, OUTPUT);
pinMode(COOL, OUTPUT);
}
void loop() {
float mix = analogRead(KNOB_COLOUR) / 1023.0; // 0 warm, 1 cool
float bright = analogRead(KNOB_BRIGHT) / 1023.0; // 0 off, 1 full
// Share the total light between the strips so the brightness stays about constant as you mix
float warm = bright * (1.0 - mix);
float cool = bright * mix;
// Square the values so the knob feels natural, since the eye sees brightness on a curve
analogWrite(WARM, (int)(warm * warm * 255 + 0.5));
analogWrite(COOL, (int)(cool * cool * 255 + 0.5));
delay(10);
}Test checklist
What you should see at each check. If a reading is far off, stop and use the troubleshooting list.
| Check | Expected |
|---|---|
| Colour knob at one end | Only warm strip lit |
| Colour knob in the middle | Both strips at half |
| Colour knob at the other end | Only cool strip lit |
| Brightness knob | Dims both together |
If it does not work
Both strips glow when off
Gate pull-down resistor missing.
Strip flickers
Check the 12 V connections and that the grounds are common.
One strip is always dim
Check the MOSFET orientation and the gate resistor.
Nano gets hot
Feed it from a 5 V buck converter instead of VIN.
Still stuck? Find the fault step by step with your multimeter →
Common questions
What parts do I need for the warm-to-cool desk lamp?
Arduino Nano, MOSFET IRLZ44N × 2, 12 V LED strip warm white (5 m, 2835), Potentiometer 10 kΩ × 2, 12 V 2 A DC adapter, Resistor 220 Ω × 2 and Resistor 10 kΩ × 2.
How long does the warm-to-cool desk lamp take to build?
About 120 minutes for a intermediate maker, in 6 steps.
How do I know the warm-to-cool desk lamp works?
Colour knob at one end: Only warm strip lit. Colour knob in the middle: Both strips at half. Colour knob at the other end: Only cool strip lit.
Both strips glow when off: what should I check?
Gate pull-down resistor missing.
Strip flickers: what should I check?
Check the 12 V connections and that the grounds are common.
One strip is always dim: what should I check?
Check the MOSFET orientation and the gate resistor.
Nano gets hot: what should I check?
Feed it from a 5 V buck converter instead of VIN.
