A Button-Controlled LED
- 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.
The first project we will do using Arduino/Genuino101 is to control the LED's on and off by button.
Picture 1: A Lamp
This is a nice and easy project! All you need to do is trigger the LED to light up by pressing down the button. Besides the Arduino/Genuino101 and the extension board, you need an LED, as well as a button. The whole project analysis is shown in Figure 1:
LED which controled by a button
The LED lights up when the button is pressed, otherwise, remain dark.
Arduino/Genuino101, Extension Board, Button, 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, button and LED.
Here we connect the button to digital pin 11, and connect the LED to digital pin 5, shown in Picture 5.
Picture 5: Diagram of the Button-Controlled LED project
To allow the lamp to be controlled by button, we need to drag and drop the DFButton, PWMLED, and To Curie nodes, and connect the nodes as shown in Picture 6. Once this is done, the knob will now control the LED.
Picture 6: Programming behind the Button-Controlled LED project
C. Set Up
Obviously, the button plays a very important role in the entire program. An interface like Picture 7 will appear if we double-click the node. Input the name you'd like, set the digital pin between 0 – 13 (for example: 11) and the function to normal button.
Picture 7: Setting up the DFButton node
Setting up the DFLed 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: DFLed node and its setting
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!