How to Adjust LED's Brightness?
- Familarize yourself with SmartNode and its interface and to understand the programming features of SmartNode
- Learn how make and control the LEDs
- Learn how to connect different models such as pins, buttons, and LEDs on the extension board.
IoT (Internet of things) literally means connecting everything by the internet. First, let's begin with lighting up an LED.
A "breathing" light is to control and adjust the brightness of an LED. A desk lamp with an adjustable brightness knob would be an example.
Picture 1: a desk lamp with an adjustable brightness knob
This is a nice and easy project! All you need to do is trigger the LED to light up by pressing down the button (rotating the knob). Besides the Arduino/Genuino101 and the extension board, you need an LED, as well as a rotation sensor. The whole project analysis is shown in Figure 1:
Figure 1: Project Analysis – How to adjust an LED's brightness?
How to adjust an LED's brightness
Use the rotation sensor to control the brightness of the LED
Arduino/Genuino101, Extension Board, Button/Knob, LED
The Arduino/Genuino 101 (Figure 2) is a development board based on an Intel® Curie™ modle, with low power consumption and offers outstanding performance. Not only the Aruduino 101 have the same features and exterior design as the Arduino UNO, but also adds Bluetooth LE capabilities, a six-axis acclerometer and a gyroscope, allowing you to have your creativity run even more wild. The Curie™ module includes an x86 Quark SE core, 32 bit ARC Zephyr, and 32MHZ clock frequency.
It is a small, yet powerful piece of technology. The Arduino/Genuino 101 can create some pretty amazing things… (Picture 3)
Picture 2: Arduino/Genuino 101 development board Picture 3: Smart cup
SmartNode is an online graphical progamming tool based on Node-Red, targeted for entry-level smart hardware developers. SmartNode is user-friendly and is quite easy to use. You do not need to download any software. All you need is a development board that supports SmartNode. Programming is divided into 4 steps:
- Drag & drop
All you must do is input the relevant parameters, link the function modules and run the program on the board. Once you've completed this, a basic smart hardware prototype is ready!
The interface of SmartNode is shown in Figure 4. Its interface is composed of three areas:
- Node area
- Working area
- Display area
Users can select desired nodes and may then drag and drop them into the working area, allowing you to begin editing.
Picture 4. Interface of SmartNode
First, we need to connect the Arduino/Genuino 101, extension board, rotation sensor and LED.
Here we connect the sensor to analog pin 0, and connect the LED to digital pin 5, shown in Picture 5.
Picture 5: Lamp connection with adjustable brightness
To allow the lamp to have adjustable brightness, we need to drag and drop the DFRotation, PWMLED, and To Curie nodes, and connect the nodes as shown in Picture 6. Once this is done, the knob will now control the brightness of the LED.
Picture 6: Programming behind the LED with adjustable brightness
C. Set up
Double-click the DFRotation node and a small pop-up window (Picture 7) will appear. Input the name you'd like, set the analog pin to 0, and the time interval to 1000.
Picture 7: Setting up the DFRotation node
Setting up the PWMLED node is quick and easy. You simply need to input a pin number. In this case, we will set the digital pin to 5, shown in Picture 8.
Picture 8: Setting up the PWMLED node
By now, you are all set!
Click "Deploy" and you will see if the LED is working as expected. If not, ask your friends or simply post your question on our forums!
Last but not least, don't forget to share your work and learning process with your friends and colleagues!
If you found this example too easy, SmartNode contains a variety of other interesting nodes, such as touch sensors for you to explore. Besides buttons and knobs, can you think of alternative ways to control an LED's brightness? Tell us some of your ideas!