I have a PIR motion sensor and would like some ultra bright UV led lights to fade in when this is triggered. It is one unit, consisting of 225 led lights connected to 240v mains (Australia). I bought a relay for the basic on/off function but was wondering if fading on and off can be done relatively easily - this is my first arduino project. I would value any suggestions.

  • You should be able to do that using a PWM signal and the "for" command. But keep in mind that you'd also need some mosfets. – Handoko Sep 6 '14 at 10:34
  • Do you have like a part number for that led unit? – Gerben Sep 6 '14 at 12:40

Most LED lights can't be dimmed from the mains supply.

In order to dim LEDs you have 2 choices: Limit the current through each LED or series string of LEDs, or pulse them very rapidly with a varying ratio of on/off times (known as a variable "duty cycle")

It's usually easiest to pulse them. To do that you need to be able to control the flow of DC to the LED array. If you were to take apart your IR array you would very likely find an AC to DC power supply that then feeds the LEDs through current limiting resistors.

If you can figure out the voltage and current that comes out of the DC power supply, you can select a power transistor (almost certainly a logic level power MOSFET) to wire in as an electronic switch that enables you to pulse the power to the LEDs using a logic signal from your Arduino.

This is actually a lot simpler than it sounds. You would cut 1 wire inside your LED array, solder in a single transistor to the 2 ends of the cut wire, and run the third wire from the transistor out to your Arduino.

Arduinos have several I/O lines that can be configured for PWM (Pulse Width Modulation) which is designed for this very purpose. You'd connect a PWM line to the gate of a logic level power MOSFET, and then send it a signal from 0 to 255, which would effectively dim the LED array in 255 brightness steps.

There are beginner sample projects that let you dim single visible light LEDs using this very approach. (For a single LED you don't need a transistor though, so they are really easy to wire up. All you need is a current limiting resistor.) I suggest you find and build one of those projects to get a feel for how (and how well) it works.

| improve this answer | |
  • So how does this connect to the mains? Do I still use the relay that I have or can I bypass that and use the arduino to talk directly with the MOSFET to dim the lights? Basically I just have a PIR sensor and when movement detected --> fade in lights. – Peeter Vedic Sep 7 '14 at 13:19
  • You could leave your IR light bank powered up all the time, and use the MOSFET to control the duty cycle of the output. However you'd then be running the power supply all the time, probably increasing wear on the IR light. It's probably better to use both a relay AND a MOSFET that controls the duty cycle of the light output. – Duncan C Sep 8 '14 at 17:24

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.