IoT LAB Manual
IoT LAB Manual
IoT LAB Manual
IoT LAB
Concept of Arduino
Arduino is a project, open-source hardware, and software platform used to design and
build electronic devices. It designs and manufactures microcontroller kits and single-board
interfaces for building electronics projects. It is an open-source platform and has a variety
of controllers and microprocessors. There are various types of Arduino boards used for
various purposes.
Arduino is an open-source electronics platform based on simple microcontroller boards
and a development environment for writing software for the boards. The boards are
equipped with sets of digital and analog input/output (I/O) pins that may be interfaced
with various expansion boards or other circuits. The boards feature an Atmel AVR
microcontroller and are pre-programmed with a boot loader that simplifies the uploading
of programs to the on-chip flash memory.
The Arduino development environment (IDE) is a cross-platform application written in
Java. It is designed to introduce programming to artists and other newcomers unfamiliar
with software development. It includes a code editor with features such as syntax
highlighting, brace matching, automatic indentation, and a program verifier that checks
the code for some common errors.
Arduino boards are widely used for DIY projects, and in many cases, the projects are
designed to interact with the physical world via sensors and actuators. Some common
examples of projects include:
• Controlling lights and motors
• Reading sensor data (e.g., temperature, humidity, light level)
• Communicating with other devices (e.g., via Bluetooth or Wi-Fi)
• Creating interactive art installations
Overall, Arduino is a simple, versatile, and affordable tool for creating electronic projects
and interacting with the physical world.
Page | 1
SCHOOL OF ENGINEERING
IoT LAB
Microcontroller ATmega328
Operating Voltage 5V
Input 7-12V
Voltage(recommended)
Input Voltage(limits) 6-20V
Digital I/O pins 14(of which 6 provide PWM
output)
Analog input pins 6
DC current per I/O pin 40Ma
DC current for 3.3V pin 50Ma
Flash Memory 32 KB(ATmega328) of which
0.5 KB
used by bootloader
SRAM 2 KB(ATmega328)
EEPROM 1 KB(ATmega328)
Clock Speed 16 MHz
Page | 2
SCHOOL OF ENGINEERING
IoT LAB
Page | 3
SCHOOL OF ENGINEERING
IoT LAB
➢ FreeRTOS library can also be installed directly through the Arduino Library
Manager. For this, open Arduino IDE and go to Sketch>>”Include Library” and click
on Manage libraries.
➢ After that, type “FreeRTOS in the search window, this library will appear. After that
click on the install button.
Page | 4
SCHOOL OF ENGINEERING
IoT LAB
void loop()
{
digitalWrite(LED,HIGH);
delay(1000);
digitalWrite(LED,LOW);
delay(1000);
}
Page | 5
SCHOOL OF ENGINEERING
IoT LAB
digitalWrite(LED1,LOW); digitalWrite(LED2,LOW);
delay(1000);
digitalWrite(LED1,LOW); digitalWrite(LED2,HIGH);
delay(1000);
digitalWrite(LED1,HIGH); digitalWrite(LED2,LOW);
delay(1000);
digitalWrite(LED1,HIGH); digitalWrite(LED2,HIGH);
delay(1000);
}
void downcounter()
{
digitalWrite(LED1,HIGH); digitalWrite(LED2,HIGH);
delay(1000);
digitalWrite(LED1,HIGH); digitalWrite(LED2,LOW);
delay(1000);
digitalWrite(LED1,LOW); digitalWrite(LED2,HIGH);
delay(1000);
digitalWrite(LED1,LOW); digitalWrite(LED2,LOW);
delay(1000);
}
Page | 6
SCHOOL OF ENGINEERING
IoT LAB
Page | 7
SCHOOL OF ENGINEERING
IoT LAB
digitalWrite(LED4,LOW); delay(1000);
digitalWrite(LED1,HIGH); digitalWrite(LED2,LOW); digitalWrite(LED3,HIGH);
digitalWrite(LED4,HIGH); delay(1000);
digitalWrite(LED1,HIGH); digitalWrite(LED2,HIGH); digitalWrite(LED3,LOW);
digitalWrite(LED4,LOW); delay(1000);
digitalWrite(LED1,HIGH); digitalWrite(LED2,HIGH); digitalWrite(LED3,LOW);
digitalWrite(LED4,HIGH); delay(1000);
digitalWrite(LED1,HIGH); digitalWrite(LED2,HIGH); digitalWrite(LED3,HIGH);
digitalWrite(LED4,LOW); delay(1000);
digitalWrite(LED1,HIGH); digitalWrite(LED2,HIGH); digitalWrite(LED3,HIGH);
digitalWrite(LED4,HIGH); delay(1000);
}
void downcounter()
{
digitalWrite(LED1,HIGH); digitalWrite(LED2,HIGH); digitalWrite(LED3,HIGH);
digitalWrite(LED4,HIGH); delay(1000);
digitalWrite(LED1,HIGH); digitalWrite(LED2,HIGH); digitalWrite(LED3,HIGH);
digitalWrite(LED4,LOW); delay(1000);
digitalWrite(LED1,HIGH); digitalWrite(LED2,HIGH); digitalWrite(LED3,LOW);
digitalWrite(LED4,HIGH); delay(1000);
digitalWrite(LED1,HIGH); digitalWrite(LED2,HIGH); digitalWrite(LED3,LOW);
digitalWrite(LED4,LOW); delay(1000);
digitalWrite(LED1,HIGH); digitalWrite(LED2,LOW); digitalWrite(LED3,HIGH);
digitalWrite(LED4,HIGH); delay(1000);
digitalWrite(LED1,HIGH); digitalWrite(LED2,LOW); digitalWrite(LED3,HIGH);
digitalWrite(LED4,LOW); delay(1000);
digitalWrite(LED1,HIGH); digitalWrite(LED2,LOW); digitalWrite(LED3,LOW);
digitalWrite(LED4,HIGH); delay(1000);
digitalWrite(LED1,HIGH); digitalWrite(LED2,LOW); digitalWrite(LED3,LOW);
digitalWrite(LED4,LOW); delay(1000);
digitalWrite(LED1,LOW); digitalWrite(LED2,HIGH); digitalWrite(LED3,HIGH);
digitalWrite(LED4,HIGH); delay(1000);
digitalWrite(LED1,LOW); digitalWrite(LED2,HIGH); digitalWrite(LED3,HIGH);
digitalWrite(LED4,LOW); delay(1000);
digitalWrite(LED1,LOW); digitalWrite(LED2,HIGH); digitalWrite(LED3,LOW);
digitalWrite(LED4,HIGH); delay(1000);
digitalWrite(LED1,LOW); digitalWrite(LED2,HIGH); digitalWrite(LED3,LOW);
digitalWrite(LED4,LOW); delay(1000);
digitalWrite(LED1,LOW); digitalWrite(LED2,LOW); digitalWrite(LED3,HIGH);
digitalWrite(LED4,HIGH); delay(1000);
digitalWrite(LED1,LOW); digitalWrite(LED2,LOW); digitalWrite(LED3,HIGH);
Page | 8
SCHOOL OF ENGINEERING
IoT LAB
digitalWrite(LED4,LOW); delay(1000);
digitalWrite(LED1,LOW); digitalWrite(LED2,LOW); digitalWrite(LED3,LOW);
digitalWrite(LED4,HIGH); delay(1000);
digitalWrite(LED1,LOW); digitalWrite(LED2,LOW); digitalWrite(LED3,LOW);
digitalWrite(LED4,LOW); delay(1000);
}
Code:
const int LED = 12;
const int button = 2;
int buttonstate=0;
void setup()
{
pinMode(LED,OUTPUT);
pinMode(button,INPUT);
Serial.begin(9600);
}
Page | 9
SCHOOL OF ENGINEERING
IoT LAB
void loop()
{
digitalWrite(LED,LOW);
buttonstate=digitalRead(button);
if(buttonstate==LOW)
{
digitalWrite(LED,HIGH);
Serial.println(buttonstate);
}
else
{
Serial.println(buttonstate);
}
}
Page | 10
SCHOOL OF ENGINEERING
IoT LAB
Page | 11
SCHOOL OF ENGINEERING
IoT LAB
Page | 12
SCHOOL OF ENGINEERING
IoT LAB
Page | 13
SCHOOL OF ENGINEERING
IoT LAB
Code:
#include <LiquidCrystal.h>
const int rs = 12, en = 11, d4 = 5, d5 = 4, d6 = 3, d7 = 2;
LiquidCrystal lcd(rs, en, d4, d5, d6, d7);
void setup()
{
lcd.begin(16, 2);
lcd.print("IOT-LAB RECORD!");
}
void loop()
{
lcd.setCursor(0, 1);
lcd.print(millis() / 1000);
}
Page | 14
SCHOOL OF ENGINEERING
IoT LAB
Sensor. An IR sensor is a photodiode that is sensitive to IR light. When IR light falls on the
photodiode, the resistances and the output voltages will change in proportion to the
magnitude of the IR light received.
As we know till now active IR Sensors emit Infrared waves and as well as detect Infrared
ways. The IR sensor module exactly works on the same phenomenon. The IR Sensor
module contains an Infrared LED and an infrared photodiode.
• Infrared LED: The Infrared LED looks the same as a normal LED. But the Infrared
LED emits light that is invisible to the naked eyes. Whenever the electricity is given
to the Infrared LED. it emits infrared light.
• Infrared Photodiode: The IR photodiode will be black in color as shown in the
picture above. Whenever Infrared waves are applied to the Infrared photodiode, in
result the Infrared photodiode changes its resistance, which causes a change in the
output voltages.
Code:
const int IR_sensor=7;
const int buzzer=8;
void setup()
{
pinMode(IR_sensor, INPUT);
pinMode(buzzer, OUTPUT);
Serial.begin(9600);
}
void loop()
{
int sensorValue=digitalRead(IR_sensor);
if(sensorValue==LOW)
{
Serial.println(sensorValue);
digitalWrite(buzzer,HIGH);
delay(50);
digitalWrite(buzzer,LOW);
delay(100);
}
else
{
digitalWrite(buzzer,LOW);
}
delay(200);
}
Page | 15