Day 9: Brightness of the real LED
Behind today’s door is another 1-kohm resistor. But today you don’t have to change anything in the hardware layout from yesterday. Only a small detail changes on the interface.
You don’t have to re-upload the programme because you’re simply manually adjusting the interface from yesterday. If you’d like to load the interface in the app anyway for safety’s sake, you’ll find the QR code here as usual. But then you also have to re-enter the token in your programme.
In order to make the changes manually, you first have to delete the button that was previously responsible for the LED at D9. To do this, tap briefly on the button while the interface is not started and tap the “delete” option below. There you’ll also be shown the energy that you “recycle.” Now, instead of the button, you have to insert a slider. To do this, tap on the plus sign at the top right and select “Slider_L.” The slider appears on the screen. By briefly tapping on the element, you reach its settings. Once you’re there, set “Output” to “Digital D9.” Note that after “D9” there’s a small red “PWM,” a little indication of how today’s test works. After these changes, you can start the interface by tapping the Play button at the top right.
What was previously possible only with the virtual LED is now also possible with real objects. You change the brightness of the LED at D9 by changing the slider position. Thus, for example, you can build a dimmable living room lamp that can be controlled via app. The keyword for this subject is PWM (pulse width modulation). Unlike with an incandescent light bulb, for example, you can’t simply dim an LED with less voltage. The procedure here is more complicated and functions by quickly switching the port on and off. The on and off times vary such that it looks like the LED becomes brighter or darker. The longer the on time is compared to the off time, the brighter the LED appears. The fact that the flickering of the LED can’t be seen or can barely be seen is due to the high speed with which the port is switched. With this procedure, you can also control engines or generate audio signals.