Delayed Light

Delayed Light

Objective:

  • Learn how to make a delayed light correctly.
  • Learn how to use the "change" and "delay" nodes correctly 
  • Familarize yourself with data transfer rules between nodes

I. Overview 

IoT (Internet of things) is an extension from the basis of internet. its core and foundation is still the internet. Before we learn how to use the SmartNode to realize a powerful loT, we need to learn everything from scratch. In today's passage, we will make a delayed LED light operated by a button with the Arduino/Genuino101.

201412021657436473

Picture 1: A traditional household light

II. Analysis 

SmartNode transmits data flow via different nodes, so the key aspect of making a delayed light is to contol the in and out data flows via nodes. We also need to utilize the "change" and "delay" nodes. The entire project analysis is shown in Figure 1.

Figure 1: Project Analysis -Delayed light

Project Name

Delayed light

Function 

When the button is pressed, the LED light will turn on for a certain period of time and then turn off.

Material List

Arduino/Genuino101, Extension Board, Button, LED

III. Basics

A Button

A button, also known as a push button, is a common control of electrical components, which is often used to connect or disconnect a controlling circuit. It is a switch that controls the deployment of motor and/or other electrical equipment. The button we are going to use belongs to the "press type digital input module" category. It can not only create interesting interactive products, but can also offer a convenient  "plug-and-use" experience. There are two states: Press or Release. 1 (HIGH) and 0 (LOW) represent Press and Release respectively. All the button modules are connected to the digital pin of the Arduino/Genuino101

bitmap

Picture 2: Digital Push Button

B.LED Light

LED light is the most popular entry-level product. It has basic functionalities and is simple to use for all beginners. The on and off of the LED can be controlled by the digital port and the brightness of the LED can be controlled by analog port. If the current level is high, it means "on", otherwise it means "off" in the LED module.

g23286

Picture 3: LED light

C.Data transfer rules 

SmartNode transfers data by means of node data flow (from left to right) by default. LED only accepts 0 and 1 (two kinds of data) in this case, so we need to  use "change" node to transfer data. As Picture 4 suggests, data is separated into two parts once the "DFButton" is triggered: part of it is directly transfered to LED through the "change" node (on), while the rest is transfered to the "delay" and "change" nodes (off) and then to the LED.

Picture 4: Data transfer case

IV. Tutorial

A. Connection

First, we need to connect the Arduino/Genuino 101, extension board, rotation sensor and LED.

Here we connect the button to analog pin 11, and connect the LED to digital pin 5, shown in Picture 5.

Picture 5: Delayed light connection diagram

B. Program

To achieve the functionality of a delayed light, we need to trigger the button and use the "Delay" node to control the LED. Thus, we can control the transfer of information by controlling the connection of the nodes, shown in Picture 6.

Picture 6: Programming behind the delayed light

C Set up

Double-click the DFButton node and a small pop-up window (Picture 7) will appear. Input the name you'd like, set the digital pin to 11 and the function of the button.

Picture 7: Setting up the DFButton node

Delay node literally means delaying the time period of the transfer from the pervious node to the next. Modules have been subpackaged in the SmartNode, so the users just need to drag and connect. The settings are pretty easy, shown Picture 8: chose "delay" under the "function" and set the time to 4 seconds. In order to make the program readable, we can also name the node.

Picture 8: Setting up the Delay node

The main function of the "change" node is to conditionally distribute the input information, functioned as "switch" and "if else" in the code. You can also click the "+rule" in the left corner to add a branch. We will set the rules to 1 to turn the LED light on and 0 to turn it off, as Picture 9 shows.

Picture 9: Setting up the Change node

Setting up the LED node is rather easy. We simply need to set the digital pin based on our needs. In this case, we will set the pin to 5, shown in Picture 10.

Picture 10: Setting up the LED node

Now you are all set!

IV. Test

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!

V. Challenge 

Pretty easy, right? Now that you have some basic understanding on the data transfer of SmartNode, how else would you be able to use this specific node in other applications? Tell us some of your ideas!

Leave a Reply

Your email address will not be published. Required fields are marked *

Skip to toolbar