Project - Simple UDP Dimmer

This very simple Network Mains Lamp Dimmer.Motor Speed Controller uses the Annex Toolkit UDP Console as a remote network controller.

An optional LED can be used as a PWM brightness/speed indicator if wished, ledpin can be changed from 15 to your own preferred gpio.

The Blue RGB slider is used to broadcast a numeric value between 0 and 255 which is translated by the script into a number between 0 (Off) to 100 (full On) to control the dimmer module.  See the demo video

The dimmer can also be controlled by entering a value between 0 and 255 into the 'Message to Send'
window and pressing 'Enter'.

A dimmer value could similarly be broadcast from an Annex device, eg:perhaps with onboard LDR to adjust for ambient light levels..
.
Note: Because UDP is broadcast to all devices on the subnet, multiple networked devices could be synced from the same controller.
 
Basic:
'UDP Mains Dimmer - Electroguard - developed on Annex 1.41 beta 3
value=0                                          'startup brightness/speed level
dimmer.setup 4,5,0,1                       'configure dimmer module, 4 and 13 = zero crossing,  5 = pwm
dimmer.limits 0, 9500                       'configured for 50hz
dimmer.brightness value                   'set brightness to startup value
option.pwmfreq 100                          'reduce pwm frequency to reduce cpu load
ledpin=15                                        'optional pwm led indicator
pwm(ledpin)=value                            'set led brightness to startup value
udp.begin(5001)                                'change port number if wished, but must match with Toolkit UDP Console port setting
onudp udpRX                                    'incoming UDP interrupt handler
wait

udpRX:
v=val(udp.read$)
value=int(v/255*100)
pwm(ledpin)=value*10
dimmer.brightness value
pause 10
return

end
  '-----------end------------







Comentarios