Internet of Things
Internet of Things
WORKSHOP
Project - Lab – Blinking an LED Using Blockly [10 Hrs]
Objectives
Part 1: Open Packet Tracer and Examine Blockly Program for LED Blinking
Part 2: Control a RGB LED using Blockly
Background
Blockly is a visual programming language that lets users create programs by connecting blocks, that
represent different logic language structures, rather than by writing the actual code. Blockly runs
within a web browser and can translate the visually created program as JavaScript, PHP, or Python. In
this lab, you will use Blockly to examine Blockly programming and to control an LED.
Scenario
Using Blockly programming to control an IoT object LED. In this lab, Cisco Packet Tracer is used as it
provides Blockly support with IoT objects.
Required Resources
Cisco Packet Tracer 7.1.1 and above is installed and available.
In Part 1, you will access the Cisco Packet Tracer program and examine LED control using Blockly
programming.
d. Click the subcategory Actuators, select LED and drag it to the workspace.
e. Click the Connections category, select IoT Custom Cable to link MCU at port D1 and LED at port
D0.
b. Click Create.
c. Double-click main.visual. The prebuilt Blockly program displays.
Why was it not blinking when the value was not set to 1023?
The digital out takes the value 1023 as “HIGH”, and turns on the output current.
i. Change the slot value for each of the analogWrite blocks to 1. Right-click the small block with the
value of zero (0) and click duplicate. Drag the new block into the empty space next to value. Do
the same for the second analogWrite slot.
j. Change the values of the first and second analogWrite blocks and observe the different LED
brightness levels.
In Part 2, you used Blockly to control an RGB LED. An RGB can display different colors with the
combination of red, green, and blue.
c. Click RGB LED and review its specification. Note different pin inputs represent different colors.
d. Open the prebuilt Blockly program. Click MCU -> Programming. Under the note No Project
Opened, click New. In the Create Project window, enter Blinking RGB LED as the project name.
In the Template dropdown menu, select Blink – Visual.
b. From the Pin Access group, select analogWrite blocks to replace digitalWrite blocks. Also, add
a few print blocks.
Challenge
Modify the program to show a combined color from all three inputs with different, randomly generated
values for each slot.
An example is as follows:
Project: Simulate IoT based Home Automation [8 Hrs ]
2. Firstly, select Home icon at the left bottom corner and now choose the required Home components .
4. Additionally, you can change the name of Appliances by clicking on respective Appliances and select
the config option. You have to repeat the same steps to rename the other devices too.
Enter the name
5. Thus now let’s establish a wireless connection. Go to Wireless devices and choose Home Gateway
6. Now copy the SSID of Home Gateway by clicking on the Home gateway.
Copy the SSID
7. Therefore It’s necessary to configure all devices to connect wirelessly to Home Gateway.
Hence you can achieve this by right-clicking a device-> Advanced->I/O config->select PT-IOT-NW-1W.
Similarly, repeat the steps for other devices as well.
8. Then paste the SSID In each appliance by clicking on the config option. Similarly repeat the steps for
other devices as well.
10. Thus you can notice that all devices are connected to the Home Gateway
11. Now select smart device to Control and Monitor Appliances.
12. Now connect your smart device also to your Home gateway
13. Thus your smart device is connected to your Home Gateway. Click on smart device and choose
Desktop. You can now login