💬 Dimmable LED Actuator
-
@mfalkvidd Just so you know, there is no PWM involved in this sketch. I've just build this setup/node and it works great. You can see that the LED are continuously fed and brightness is changed by changing the voltage to the LEDs through the MOSFET.
-
It might be a very nice idea to use neopixels with this, a little expensive though when using a lot of LED's but still it's possible to dim them just by using code.. I am afraid I am not able to do that and it was just a small thought... :)
-
@mfalkvidd Yikes, you're right! I drew my conclusion too soon and only by watching the LED strip at max brightness. At max brightness the switching frequency is so high it is no longer perceptible by the eye. Mea culpa...
-
@mfalkvidd Yikes, you're right! I drew my conclusion too soon and only by watching the LED strip at max brightness. At max brightness the switching frequency is so high it is no longer perceptible by the eye. Mea culpa...
@Creaky yes the switching is pretty quick. I guess that's the whole idea :) I have noticed a refraction pattern in the kitchen sink when using a thin jet of water though.
The analogWrite function in Arduino is very poorly named, since it doesn't really write an analog value. But I guess it is hard to change now.
-
I plan to use a LED strip as a closet light, controlled by a magnetic door switch, and of course also controllable in Domoticz. What would be the right way to write the code, should the pro mini send the state of the magnetic switch to the controller and then let the controller turn on the light, or is it easier to let the pro mini turn on the light directly and then report the state back to the controller? Big difference in delay?
-
It's a closet with two sliding doors and therefore two magnetic switches, and I want the LED to turn on when opening one of the doors, but also be able to turn it off remotely if we forgot to close it when leaving our home.
-
I would like to use this with a 48 Watt led which uses a constant-current power supply 54 - 87 VDC 600 ma output. This mosfet isn't high enough voltage rating, the IRF630MFP is rated at 200V 9amp, however I have questions about if the uC output will power the gate. The gate-source voltage is +/- 20. The VGS(th) gate threshold voltage is 2 to 4 volts with typ 3V. I would cut the negative from the power supply and connect to source, then connect the Led negative to drain, and connect the drain to ground on the uC? I need a reality check- does this sound possible or will I fry something?
-
Hi,
I'm new in MySensors and build this Dimmer - LED with and without the rotary encoder which works fine.
Now I would like to decouple the rotary encoder as a battery powered "standalone" sensor which is (in best case) connected directly to the LED-Dimmer. Furthermore the decoupled rotary encoder should be always in sleep mode until the rotary encoder awake the arduino.
Is that possible ? I'm just stuck to seperate the code for the rotary encoder from the led-dimmer code.
Thank you in advance. -
hi, i used the example sketch. i also changed from "delay" to "wait" in fade section. The problem: i can change the percentage for example 8 times and then the gateway crashes and reboots. In a other case it works 12 times and then the gateway crashes. All other nodes (Temp, Hum) works fine all the time.
-
hi, i used the example sketch. i also changed from "delay" to "wait" in fade section. The problem: i can change the percentage for example 8 times and then the gateway crashes and reboots. In a other case it works 12 times and then the gateway crashes. All other nodes (Temp, Hum) works fine all the time.
-
Problem solved! The 3.3v Form arduino nano was too Bad for the nrf24l01j pa lna with PA_LEVEL MAX. NOW i usw an external regulator an everything is fine :-) sorry for this newbie fault :-D
-
Hi, I've noticed the V_DIMMER of the example is not (anymore?) available in https://www.mysensors.org/download/serial_api_20, am I wrong? Thanks
-
Hi, I've noticed the V_DIMMER of the example is not (anymore?) available in https://www.mysensors.org/download/serial_api_20, am I wrong? Thanks
-
Dear Guys,
How can I control an RGB ledstrip with this config may I add more MOSFAT or how ?
Thank you very much.L
-
so this works now like a charm:
// Enable debug prints to serial monitor #define MY_DEBUG // Enable and select radio type attached #define MY_RADIO_NRF24 //#define MY_RADIO_RFM69 #define MY_NODE_ID 153 #include <SPI.h> #include <MySensors.h> #define SN "MultiDimmableLED" #define SV "1.1" #define noLEDs 3 const int LED_Pin[] = {3, 5, 6}; #define FADE_DELAY 25 // Delay in ms for each percentage fade up/down (10ms = 1s full-range dim) static int currentLevel = 0; // Current dim level... MyMessage dimmerMsg(noLEDs, V_DIMMER); MyMessage lightMsg(noLEDs, V_LIGHT); /*** * Dimmable LED initialization method */ void setup() { // not sure this works // Pull the gateway's current dim level - restore light level upon sendor node power-up for (int sensor=1; sensor<=noLEDs; sensor++){ request( sensor, V_DIMMER ); } } void presentation() { // Register the LED Dimmable Light with the gateway for (int sensor=1; sensor<=noLEDs; sensor++){ present(sensor, S_DIMMER); wait(2); } sendSketchInfo(SN, SV); } /*** * Dimmable LED main processing loop */ void loop() { } void receive(const MyMessage &message) { if (message.type == V_LIGHT || message.type == V_DIMMER) { // Retrieve the power or dim level from the incoming request message int requestedLevel = atoi( message.data ); // Adjust incoming level if this is a V_LIGHT variable update [0 == off, 1 == on] requestedLevel *= ( message.type == V_LIGHT ? 100 : 1 ); // Clip incoming level to valid range of 0 to 100 requestedLevel = requestedLevel > 100 ? 100 : requestedLevel; requestedLevel = requestedLevel < 0 ? 0 : requestedLevel; Serial.print( "Changing LED " ); Serial.print(message.sensor); Serial.print(", PIN " ); Serial.print( LED_Pin[message.sensor] ); Serial.print(" level to " ); Serial.print( requestedLevel ); Serial.print( ", from " ); Serial.println( currentLevel ); fadeToLevel( requestedLevel, message.sensor ); // Inform the gateway of the current DimmableLED's SwitchPower1 and LoadLevelStatus value... send(lightMsg.set(currentLevel > 0 ? 1 : 0)); // hek comment: Is this really nessesary? send( dimmerMsg.set(currentLevel) ); } } /*** * This method provides a graceful fade up/down effect */ void fadeToLevel( int toLevel, int ledid ) { int delta = ( toLevel - currentLevel ) < 0 ? -1 : 1; while ( currentLevel != toLevel ) { currentLevel += delta; analogWrite(LED_Pin[ledid-1], (int)(currentLevel / 100. * 255) ); wait( FADE_DELAY ); } }``` thank you :thumbsup: -
Ah I have just built a test bed with this setup however it appears the circuit diagram in the Fritizing is actually not 100% correct. The red wire from the protoboard is connected to the GND of the Pro Mini - this confused me as I was using the GND/RAW pins to identify the cable color. If you flip the red/blue connections on the Pro Mini it will be right. Small issue I know but I had to reference another image to get the circuit to work.