The door of day 14 reveals another LED. Now we have two LEDs with resistors and two buttons and 14. Tag cables, enough to build a complex lighting system. We will use the following setup:

Der Aufbau mit vier losen Kabeln (gelb) als Touch-Buttons
Setup with four loose cables (yellow) as touch buttons

Enable today’s program and install today’s flow. Don’t forget, replace [PID] with your personal ID and the easiest way is using the trick with the Editor.

The LEDs in the program you just enabled are set as PWM LEDs. This means that you can change the brightness of the LEDs. The values range from 0 to 255. Beside that however, you can still switch LEDs on or off like digital outputs. Use the following commands:

Command in topicSettings
{“cmd”:“set_pwm_state”, “LED1”:255}The LED is set to maximum brightness. You can see it only when the LED is on.
{“cmd”:“set_pwm_state”, “LED1”:0}The LED is set to the minimum brightness (the LED is not on).
{“cmd”:“set_pwm_state”, “LED1”:true}The LED is activated and the last brightness is set. You will immediately notice any changes in brightness.
{“cmd”:“set_pwm_state”, “LED1”:“ON”}
{“cmd”:“set_pwm_state”, “LED1”:false}The LED is deactivated. You will notice a change in brightness only after activating the LED again.
{“cmd”:“set_pwm_state”, “LED1”:“off”}

These status changes can be sent via the out topic or NodeESP/[PID]/pwm/state/set. In case of a status change, the current state will also be published via the topic

NodeESP/[PID]/pwm/state/get/out

In today’s program we have two buttons and four touch buttons activated, which function according to the method we already know. The Node-RED flow today is a bit bigger, because we have an UI button for every button and every setting.

Das Userinterface des heutigen Programms
User interface of the program today

The user interface already provides some hints how the experiment today will work. The two LEDs simulate two dimmable lamps in a home. They are switched on or off with the two buttons on the board or via the web interface. The brightness can be adjusted using the UI controls. The buttons below are used to change the brightness by +10 or -10. The touch buttons have the same function. If you touch the wire pictured on the left in the setup figure, you will decrease the brightness of the LED on the left-hand side over time. The wire on the very the right increases the brightness. The two remaining wires work for the right LED in the same way. You can also change the brightness, if the LED is not on. The change will become noticeable only after you turn the LED on. The function is still very useful in case, you want to adjust the brightness of the lamp depending on the time of day, for example

Der Flow des Tages
The flow today
External content from pastebin.com
Loading it sends data such as your IP address to pastebin.com. Privacy
open directly ↗