Iot Lab Record
Iot Lab Record
DESCRIPTION:
Connecting the LED to the circuits and making the LED to GLOW ON and OFF with some
time delay.
PROGRAM:
int LED_BUILTIN = 13; // pin D13 is by default assigned as the output pin for LED’s
// the setup function runs once when you press reset or power the board
void setup() {
// initialize digital pin LED_BUILTIN as an output.
pinMode(LED_BUILTIN, OUTPUT);
}
IMPLEMENTATION/PROCEDURE:
1. H/W REQUIREMENTS:
a. Arduino Nano,
b. Resistor 220 ohm,
c. LED (any colour),
d. Jumper wires.
2. S/W REQUIREMENTS:
a. Arduino IDE,
b. Arduino Drivers,
c. Windows OS,
STEP 1: Open the arduino IDE and write the above program to blink an LED.
STEP 2: After writing the program we can save it with a file name of your choice (find File–>Save
on menu bar of IDE)
B) Select the right port -- The port number is assigned while installing the hardware driver
of board. You can find the port number by accessing device manager on Windows. See
the section Port (COM & LPT) and look for an open port named “Arduino Uno
(COMxx)“. If you are using a different board, you will find a name accordingly. What matters
is the xx in COMxx part. In my case, its COM5. So my port number is 5.
To select the right port, go to Tools–> Serial Port and select the port number.
Now everything is ready. Your arduino board is ready to communicate with your PC and vice
versa. Instructions will be send to arduino board from your PC.
STEP 4: Now we have to load the program from the Pc to the Arduino Nano Board. There are two
steps involved in loading the program from your PC to Arduino board via the arduino
IDE. First step is compiling and second step is called burning.
A) Compiling – This is the process of converting the code you have just written in Arduino
IDE to another form which is only understood by the micro controller in your
arduino board. In our example, we use Arduino uno board. It is made using Avr
micro controller (Atmega328). In the arduino IDE, compiling is called as “verify“.
So hit the verify button in your IDE (see the button with tick mark just below menu
bar). Refer the screenshot given below as well. When you hit the verify button, the
program you have written in arduino IDE will be compiled for any errors and then
converted to another form that Avr Atmega328 understands. You may refer our
article on the Arduino Software and Hardware to know in detail about the language
used in arduino.
B) Burning – Embedded designers use the word “burning” to refer to uploading a program
to any micro controller. So in this step, we are going to upload the verified program
in Arduino IDE to the Arduino board. To do this, press the “upload” button (see
the button with right arrow mark). A click on the “upload” button will begin the
process of burning the compiled program to Avr micro controller on your Arduino
board. Depending on the size of your program, this will take a little time. If you look on
your Arduino board, you can see the 2 LED’s near Tx and Rx blinking. This is an
indication of successful communication between your PC and Arduino board. If the
program has been uploaded successfully, you will see a message like “Done Uploading“.
If the uploading process was not successful, you will see an error message
accordingly. Refer the screenshot given below.
Note: While I was uploading the “classic LED blink” program to my Arduino board, I got an error
message on first attempt. It was like “Port COM5 is already in use by another device”. I got it fixed
by plugging the board to another USB port in my laptop.
OUTPUT:
DESCRIPTION:
To connect a series of LED of different colours and allow them to BLINK with some delays
using Resistors.
PROGRAM:
CIRCUIT DIAGRAM:
IMPLEMENTATION/PROCEDURE:
1. H/W REQUIREMENTS:
a. Arduino Nano,
b. Resistors 220 ohm,
c. LED’s (all colours),
d. Jumper wires.
2. S/W REQUIREMENTS:
a. Arduino IDE,
b. Arduino Drivers,
c. Windows OS,
Basically you've connected the LED and resistor in series (one after the other) to a 5V
'battery'. The positive pin of the LED is connected to the positive terminal of the battery, then the
negative pin is connected to a resistor which goes to the negative terminal of the battery. The battery
is supplying the current that flows through the LED, making it light up.
The positive and negative battery terminals are often called the power supply, as they supply
power to our circuit. The positive terminal is called power (as that where current flows from) and the
negative terminal is called ground, as it is where current flows to.
The digitalWrite procedure connects the pin indicated by the first input (ledPin) to either the
+5V power supply or to ground depending on the second input (HIGH or LOW)
Three resistors are required - one for each LED. Use RED, GREEN and BLUE LEDs.
STEP 1: Connect the GND pin to the blue line in the breadboard. This will give you a common
ground for your circuit.
STEP 2: Connect one leg of your resistors to the ground and the other leg to one of the LED. Repeat
for each LED as shown in the diagram.
OUTPUT:
ACTUAL:
CONCLUSION:
The LED’s connected serially using resistors and allowed them to BLINK with some
delay intervals. The program is compiled and executed successfully.
AIM: To Make an RGB LED to glow with different colours.
DESCRIPTION:
RGB LED – these are three LEDs of different colors (Red – red, Green –green, Blue – blue),
enclosed in one package. The difference between RGB LEDs with a common anode and a common
cathode.
RGB LEDs are of two types: with a common anode (“plus”) and a common cathode
(“minus”).. The long leg of the LED is always the common power pin. Separately, the red LED
output (R) is located, green (G) and blue (B) are located on the other side of the common output. The
LED, in turn, lights up in red, green and blue. Each color burns for 0.1 seconds, and then goes out for
0.2 seconds, and the next one turns on.
PROGRAM:
void loop()
{
// put your main code here, to run repeatedly:
digitalWrite(pinR, LOW);
delay(100);
digitalWrite(pinR, HIGH);
delay(200);
digitalWrite(pinG, LOW);
delay(100);
digitalWrite(pinG, HIGH);
delay(200);
digitalWrite(pinB, LOW);
delay(100);
digitalWrite(pinB, HIGH);
delay(200);
}
CIRCUIT DIAGRAM:
IMPLEMENTATION/PROCEDURE:
An RGB LED is a light emitting diode which can display any color we want. It consists of 3
discrete LEDs, a RED, a GREEN, and a BLUE LED housed in a single package. So by combining
these 3 colors we can create any color. As you can see, the RGB LED has 4 pins. So far the LEDs we
were using only had 2 pins. The pins are used in order to control the color of the LED. The longest
pin is either the anode or the cathode depending on the type of the RGB LED. The LED I have
bought is a common cathode LED so the longest leg will be connected to GND. If it was a common
anode LED, the longest pin would connect to 5V. The other three pins are Red, Green, and Blue.
1. H/W REQUIREMENTS:
a. Arduino Nano,
b. Breadboard
c. RGB LED
d. Resistor 330 ohm
e. Connecting Wires
2. S/W REQUIREMENTS:
a. Arduino IDE,
b. Arduino Drivers,
c. Windows OS,
CONCLUSION:
Glowing RGB LED in RED, GREEN, BLUE colours is compiled and executed successfully.
AIM: Connect a LED with TOGGLE button using Arduino.
DESCRIPTION:
Digital input is taken through push button and that is detected by Arduino Nano. This input is
processes by Arduino Nano and it send digital command to attached LED. When we press the button
LED glows.
PROGRAM:
1. H/W REQUIREMENTS:
a. Arduino Nano,
b. Mini USB Cable
c. Breadboard
d. LED
e. Resistor 220 ohm and 10k
f. Push button
g. Male to Male Jumper Wire
2. S/W REQUIREMENTS:
a. Arduino IDE,
b. Arduino Drivers,
c. Windows OS,
Place a pushbutton in the breadboard. They should be properly fixed. The legs should tightly
fixed or else it will not work. Put a 10k resistor to one leg on any column. On the other end connect
the hole through a jumper wire to 5v.
Now the one leg of Push Button is connected to 5v supply and the other one is connected with
LED via the resistor, as shown in circuit diagram. Initially, Push Button does not allow the current to
flow through it, but when it is pressed it completes the circuit and LED will start to glow. The current
will pass till the button is pressed, as soon as we release it, the LED will be turned off as push-button
breaks the circuit and stop the supply.
OUTPUT:
CONCLUSION:
Connecting LED with button using Arduino is compiled and executed successfully.
AIM: To Detect Light with LDR and represent that using Serial Monitor or LED.
DESCRIPTION:
The Arduino Nano for LED light is turned on or off by the light-sensitive resistor to the
surrounding ambient light. A photoresistor or photocell is a light-controlled variable resistor. The
resistance of a photoresistor decreases with increasing incident light intensity. A photoresistor can be
applied in light-sensitive detector circuits, and light- and dark-activated switching circuits. It's also
called light-dependent resistor (LDR).
PROGRAM:
CIRCUIT DIAGRAM:
IMPLEMENTATION/ PROCEDURE:
The resistance value becomes smaller when there is much light. So in the dark the led remains
off because the resistance has become very big.
1. HARDWARE REQUIREMENTS:
a. Arduino Nano
b. USB Cable
c. Red LED
d. 220Ω Resstor
e. 10kΩ ResistoR
f. Photo resistance
g. Breadboard
h. Several jumper wires.
2. SOFTWARE REQUIREMENTS:
d. Arduino IDE,
e. Arduino Drivers,
f. Windows OS,
CONCLUSION:
To Detect Light with LDR and represent that using LED is compiled and
executed successfully.
AIM:
To Detect Temperature & Humidity using DHT11 sensors and send to PC via serial.
DESCRIPTION:
To read DHT11 (Temperature & Humidity sensors) values, and send data to PC via serial. For
this the library adafruit/DHT-sensor-library is used to read DHT11.
PROGRAM:
CIRCUIT DIAGRAM:
IMPLEMENTATION/ PROCEDURE:
1. H/W REQUIREMENTS:
d. Arduino Nano,
e. Mini USB Cable
f. Breadboard
g. LED
h. Resistor 220 ohm and 10k
i. DTH11 Sensor
j. Male to Male Jumper Wire
2. S/W REQUIREMENTS:
k. Arduino IDE,
l. Arduino Drivers,
m. Windows OS,
There are four legs in DTH11 sensor, 1 leg you connect to 5V, another leg not connected to
any pins of Arduino Nano, another leg to Ground, another leg to D2 of Arduino Nano and Resistors
as given in the Diagram given below.
Now Place a DTH11 sensor in the breadboard. They should be properly fixed. The legs
should tightly fixed or else it will not work. Put a 10k resistor to one leg on any column. On the other
end connect the hole through a jumper wire to 5v. other end of the resistor is connected to the D2
digital input pin of Arduino Nano.
Now the one leg of DTH11 sensor is connected to 5v supply and the D2 pin via the resistor, as
shown in circuit diagram. One leg is connected to D2 directly, One leg is connected to Ground. One
Leg of DTH11 sensor is not connected to anywhere. By executing the program and uploading you
can view the Sensor Data in the window like DHTtester.ino which shows the Humidity and
Temperature (C & F), Heat Index everything is taken as output.
OUTPUT:
CONCLUSION:
Thus reading DHT11 (Temperature & Humidity sensors) values, and send data to PC via
serial with DTH11 Sensor and Arduino Nano is compiled and executed successfully.