SBC Lab Manual
SBC Lab Manual
LABORATORY REPORT
ELECTRICAL ENGINEERING
Section: Diploma
Semester: 4TH
1
SBC Based System Design & IoT
COURSE NAME:
List of Experiments:
INDEX
Exp.
Page
No. Date Name of The Experiments
No.
19.01.2022 Write a program to Blink LED using Arduino UNO.
4-5
1.
2
SBC Based System Design & IoT
27.01.2022 Write a program to Interface Temperature and Humidity sensor
(DHT11) With Arduino.
6. 21-23
02.02.2022
8 Write a program to Interface IR Module with Arduino UNO 28-31
3
SBC Based System Design & IoT
APPARTUS REQUIRED:
CODE:
4
SBC Based System Design & IoT
int ledPin=8;
void setup()
pinMode(ledPin,OUTPUT);
void loop()
digitalWrite(ledPin,HIGH);
delay(1000);
digitalWrite(ledPin,LOW);
delay(1000);
THEORY:
In this lesson, we will program the Arduino's GPIO output high level (+5V) and low level (0V), and then make
the LED which is connected to the Arduino’s GPIO flicker with a certain frequency.
The LED is the abbreviation of light emitting diode. It is usually made of gallium arsenide, gallium phosphide
semiconductor materials. The LED has two electrodes: a positive electrode and a negative one.
The main function of the resistor is to limit currents. In the circuit, the character ‘R’ represents resistor, and the
unit of resistor is ohm(Ω).
PROCEDURE:
● Connect the long leg of the LED (the positive leg, called the anode) to the other end of the resistor.
● Connect the short leg of the LED (the negative leg, called the cathode) to the GND.
5
SBC Based System Design & IoT
CONCLUSION:
After upload done, we have concluded that the on-board LED blink every second.
Experiment No.2
APPARTUS REQUIRED:
6
SBC Based System Design & IoT
CODE:
int i = 0;
void setup()
pinMode(LED, OUTPUT);
void loop()
analogWrite(LED,i);
delay(wait);
7
SBC Based System Design & IoT
}
analogWrite(LED,i);
delay(wait);
THEORY:
In order to fade your LED off and on, gradually increase your PWM value from 0 (all the way off) to 255
(all the way on), and then back to 0 once again to complete the cycle. In the sketch below, the PWM value is
set using a variable called brightness.
The LED is the abbreviation of light emitting diode. It is usually made of gallium arsenide, gallium phosphide
semiconductor materials. The LED has two electrodes: a positive electrode and a negative one.
The main function of the resistor is to limit currents. In the circuit, the character ‘R’ represents resistor, and the
unit of resistor is ohm(Ω).
PROCEDURE:
● Connect the long leg of the LED (the positive leg, called the anode) to the other end of the resistor.
● Connect the short leg of the LED (the negative leg, called the cathode) to the GND.
CONCLUSION:
After upload done, we have seen the on-board LED gradually increase the brightness and then gradually
decrease the brightness.
8
SBC Based System Design & IoT
Experiment No.3
APPARTUS REQUIRED:
9
SBC Based System Design & IoT
2 LCD Display 16 * 2 1
3 Resistor 220 ohms 1
4 Jumper wires Male-male As per
Female-male requirement
5 Bread Board mini 1
CODE:
#include<LiquidCrystal.h>
void setup()
lcd.begin(16, 2);
void loop()
lcd.setCursor(0,0);
10
SBC Based System Design & IoT
lcd.setCursor(2,1);
THEORY:
The process of controlling the display involves putting the data that form the image of what you want to display
into the data registers, then putting instructions in the instruction register. The Liquid Crystal Library simplifies
this for you so you don't need to know the low-level instructions.
The Hitachi-compatible LCDs can be controlled in two modes: 4-bit or 8-bit. The 4-bit mode requires seven I/O
pins from the Arduino, while the 8-bit mode requires 11 pins. For displaying text on the screen, you can do most
everything in 4-bit mode, so example shows how to control a 16x2 LCD in 4-bit mode.
The main function of the resistor is to limit currents. In the circuit, the character ‘R’ represents resistor, and the
unit of resistor is ohm(Ω).
PROCEDURE:
To wire your LCD screen to your board, connect the following pins:
CONCLUSION:
After upload done, I will see that the LCD Display is showing ‘Hello World ‘
11
SBC Based System Design & IoT
Experiment No.4
APPARTUS REQUIRED:
CODE:
int sensorValue = 0;
void setup()
pinMode(A0, INPUT);
Serial.begin(9600);
pinMode(9, OUTPUT);
void loop()
13
SBC Based System Design & IoT
{
sensorValue = analogRead(A0);
Serial.println(sensorValue);
if(sensorValue>=852){
digitalWrite(9,HIGH);
}else{
digitalWrite(9,LOW);
THEORY:
LDR sensor module is a low-cost digital sensor as well as analog sensor module, which is capable to measure
and detect light intensity. This sensor also is known as the Photoresistor sensor. This sensor has an onboard
LDR (Light Dependent Resistor), that helps it to detect light. This sensor module comes with 4 terminals.
Where the “DO” pin is a digital output pin and the “AO” pin is an analog output pin. The output of the module
goes high in the absence of light and it becomes low in the presence of light. The sensitivity of the sensor can be
adjusted using the onboard potentiometer.
LDR Sensor Module or Photoresistor sensor Pin Diagram
14
SBC Based System Design & IoT
Pin No Pin Name Description
PROCEDURE:
● Connect the Analog pin A0 one of the end of the 4.7 kΩ resistor and to the negative pin of LDR
● Connect the long leg of the LED (the positive leg, called the anode) to the Digital pin 9
CONCLUSION:
After upload done, we have seen that the led is adjusting its brightness according to the surrounding light of
LDR.
15
SBC Based System Design & IoT
03 Smoke detection MQ-2 01
sensor
04 Resistor 221ohm 01
05 LED RED(5mm) 01
Green(5mm) 01
06 Buzzer 01
07 Jumper Wire Single Strand As per requirement
16
SBC Based System Design & IoT
Theory
17
SBC Based System Design & IoT
MQ-2 sensor
18
SBC Based System Design & IoT
The output can be an analog signal (A0) that can be read with an analog input of the Arduino or a digital output
(D0) that can be read with a digital input of the Arduino.
CODE
void setup () {
void loop () {
Serial.println(analog Sensor);
else
no Tone(buzzer);
delay (100);
Procedure
From the above experiment we have concluded that MQ sensor is working properly with Arduino through
programming.
20
SBC Based System Design & IoT
21
SBC Based System Design & IoT
Aim of the Exp:
Write a program to Interface Temperature and Humidity sensor (DHT11) With Arduino.
Theory
Humidity is the water vapor around you mixed with air. It is measured in per cents. So, if the humidity is 60 per
cent (which is the average humidity), then 60 per cent of the air around you are water vapor. If it is 100%, then
it means either the sensor is not correct, the sensor is broken/damaged, the Arduino crashed, the Arduino can't
receive any signal, there's an error in the code or you're underwater*. If it's 0%, it means all the reasons above
except the last one, you're in space or you're in the middle of a desert**.
* Correction: it means the air cannot hold any more water.
** The air in a desert does contain some water but it is a very little amount compared to a normal place. The
Sahara Desert has a mean humidity of 25%.
22
SBC Based System Design & IoT
CODE
#include <dht11.h>
#Define DHT11PIN 4
dht11 DHT11;
void setup ()
{
Serial. Begin (9600);
void loop ()
{
Serial.println();
delay (2000);
Procedure
Conclusion
From the above experiment we have concluded that DHT-11 sensor is working properly with Arduino through
programming.
23
SBC Based System Design & IoT
Experiment No.7 Date:
Theory
A relay is an electromechanical switch used mainly for switching application either high voltage or low voltage
switching, and they can be also used with microcontrollers like the Arduino for controlling high voltage devices
24
SBC Based System Design & IoT
Relay Module
The aim of writing this is to serve as a guide while to interface the relay and the Arduino or the ESP 32
We'll be using the Arduino, Relay Module, Wires, LED (green) and a 220-ohm resistor
Input Side
25
SBC Based System Design & IoT
Output Side
The relay pinout is as follows;
On the Input side
Positive ---- "5v or External 5v Power Supply"
Control/Signal pin ----- "digital Write pins on the Arduino "
Negative ---- "Ground"
On the Output Side
Normally Closed ---- "preferably Empty"
Ground ----- "Ground"
Normally Open ---- "Negative Terminal of the Load "
Things to note when working with your Relay
* The relay is not an ideal switch...meaning don't use your relay for basic switching purpose like turning on/off
LED...it will wear off the mechanical parts faster...this example was just for demonstration
* They are not good for fast switch application
26
SBC Based System Design & IoT
* Relays are more suitable for high voltage application or relatively slow switching like controlling servos.
CODE
/* Relay and Arduino >>>> code by @_carlos_dev */
void setup () {
// put your setup code here, to run once:
pinMode(relayPin, OUTPUT); //Setting the Relay pin as an Output Pin
}
void loop() {
// put your main code here, to run repeatedly:
digitalWrite(relayPin, HIGH); //Turn the relay ON for 1 second
delay(1000);
digitalWrite(relayPin,LOW); //Turn the relay OFF for 1 second
delay(1000);
}
Procedure
● Connect signal pin to the digital pin 8
● Connect the long leg of the LED (the positive leg, called the anode) to the other end of the resistor.
● Connect the short leg of the LED (the negative leg, called the cathode) to the GND.
Conclusion
From the above experiment we have concluded that Relay Module is working properly with Arduino through
programming.
27
SBC Based System Design & IoT
28
SBC Based System Design & IoT
Write a program to Interface IR Module with Arduino UNO.
Theory
IR Infrared Obstacle Avoidance Sensor Module has a pair of infrared transmitting and receiving tubes.
When the transmitted light waves are reflected back, the reflected IR waves will be received by the
receiver tube. The onboard comparator circuitry does the processing and the green indicator LED comes
to life.
The module features a 3-wire interface with Vcc, GND and an OUTPUT pin on its tail. It works fine with
3v3 to 5V levels. Upon hindrance/reflectance, the output pin gives out a digital signal (a low-level signal).
The onboard preset helps to fine tune the range of operation, effective distance range is 2cm to 80cm.
29
SBC Based System Design & IoT
Features:
Package Includes:
Code
void setup () {
void loop () {
30
SBC Based System Design & IoT
// put your main code here, to run repeatedly:
else {
digital Write(12,LOW);
Procedure
● Connect the long leg of the LED (the positive leg, called the anode) to the other end of the resistor.
● Connect the short leg of the LED (the negative leg, called the cathode) to the GND.
Conclusion
From the above experiment we have concluded that IR sensor is working properly with Arduino through
programming.
31
SBC Based System Design & IoT
List of equipment / tools:
Code
intcalibrationTime = 30;
//the time when the sensor outputs a low impulse
longunsigned intlowIn;
//the amount of milliseconds the sensor has to be low
//before we assume all motion has stopped
longunsigned intpause = 5000;
boolean lockLow = true;
32
SBC Based System Design & IoT
boolean takeLowTime;
intpirPin = 12; //the digital pin connected to the PIR sensor's output
intledPin = 13;
////
//SETUP
voidsetup(){
Serial.begin(9600);
pinMode(pirPin, INPUT);
pinMode(ledPin, OUTPUT);
digitalWrite(pirPin, LOW);
//give the sensor some time to calibrate
Serial.print("calibrating sensor ");
for(inti = 0; i < calibrationTime; i++){
Serial.print(".");
delay(1000);
}
Serial.println(" done");
Serial.println("SENSOR ACTIVE");
delay(50);
}
//LOOP
voidloop(){
if(digitalRead(pirPin) == HIGH){
digitalWrite(ledPin, HIGH); //the led visualizes the sensors output pin state
if(lockLow){
lockLow = false;
Serial.println("---");
Serial.print("motion detected at ");
Serial.print(millis()/1000);
Serial.println(" sec");
delay(50);
}
takeLowTime = true;
}
if(digitalRead(pirPin) == LOW){
digitalWrite(ledPin, LOW); //the led visualizes the sensors output pin state
if(takeLowTime){
lowIn = millis(); //save the time of the transition from high to LOW
takeLowTime = false;
}
//if the sensor is low for more than the given pause,
//we assume that no more motion is going to happen
if(!lockLow && millis() - lowIn > pause){
//makes sure this block of code is only executed again after
//a new motion sequence has been detected
lockLow = true;
Serial.print("motion ended at "); //output
Serial.print((millis() - pause)/1000);
33
SBC Based System Design & IoT
Serial.println(" sec");
delay(50);
}
}
}
Theory
Theory:
PIR SENSOR: - A passive infrared sensor (PIR sensor) is an electronic sensor that measures infrared (IR)
light radiating from objects in its field of view. They are most often used in PIR-based motion detectors. PIR
sensors are commonly used in security alarms and automatic lighting applications.
Procedure: -
Most PIR modules have a 3-pin connection at the side or bottom. The pinout may vary between modules so
check the pinout carefully! Power is usually 3-5v DC input.
Conclusion
From the above experiment we have concluded that this experiment is working properly with Arduino UNO.
34