How To Make a Dimmer for a Light Fixture w/ High-Powered LEDs

With the following parts, including some aluminium and walnut I made an LED lighting fixture with a PWM dimmer switch.

The code at the bottom will run on any arduino, although I used a 5 volt Adafruit trinket running at 8 mhz to control the switching on the transistor.


LED Lighting Fixture Parts - (Affiliate Links)


Arduino-Based Dimmer Code for the Light

const byte potIn = 2; // reads the value from the potentiometer
const byte ledOut = 0; // assigns the output to pin #0 on the trinket
int potValue; 
int ledValue;
 
void setup() {
pinMode(ledOut, OUTPUT);
}
 
void loop() {
potValue = analogRead(potIn); // reads value of the potentiometer
ledValue = map(potValue, 0, 1024, 0, 255); // assigns a number relative to the voltage output
analogWrite(ledOut, ledValue); // outputs a voltage number to the led
}


Previous
Previous

Ultimate DIY Small Parts Organization Caddy

Next
Next

Should We Delete Memories? Space Travel, Books & More! Podcast 06