Practical Work 1 Q - December 2020

Download as pdf or txt
Download as pdf or txt
You are on page 1of 11

DEPARTMENT OF INFORMATION & COMMUNICATION TECHNOLOGY

DFN40242 EMBEDDED INTERNET OF THINGS


PRACTICAL WORK 1| SESSION DECEMBER 2020
DURATION 2 HOURS

TOPIC 2: SENSORS, ACTUATORS, AND MICROCONTROLLERS

CLO 2P: Demonstrate entrepreneurial and good managerial skills in proposing IoT solutions
to solve problems. (A3, PLO 7)

OBJECTIVES :
By the end of this lab, students should be able to:

1. Build a simple system controlled by a microcontroller.


2. Perform microcontroller configuration to monitor a variety of sensor/inputs.
EQUIPMENT :

• TinkerCad

ACTIVITY A: Photoresistor sensor

Operation and uses:

The photoresistor is an electronic component which resistivity varies according to the


amount of light received (the resistance decreases when exposed to the light).
The photoresistor is made of cadmium sulphide tape, a semiconductor.
When photons hit the tapes, electrons can pass through the semiconductor.
The main use of the photoresistor is the measurement of the luminous intensity (camera,
detection systems, and etc).

Procedure:

1. Follow the circuit diagram and make the connections as shown in the image given
using TinkerCad software.

Connections:

Photoresistor :
First pin --> 5V

Second pin --> A0 (a resistance is connected to the GND and to the photoresistor second
pin).

Components

a- Microcontroller Arduino Uno R3


b- Photoresistor
c- Resistor 10KΩ
d- Breadboard Small

2. Type the text code given.

Text Code:

3. Run the simulation (make sure no error detection).


4. Show the result.
Result:

*click at the photoresistor sensor, the adjustment controller will pop up. Adjust the controller and see the
result at the serial monitor.

ACTIVITY B: Ultrasonic sensor

Operation and uses:

The HC-SR04 ultrasonic sensor uses SONAR to determine the distance of an object just like the
bats do. It offers excellent non-contact range detection with high accuracy and stable readings
in an easy-to-use package from 2 cm to 400 cm or 1” to 13 feet.

The operation is not affected by sunlight or black material, although acoustically, soft materials
like cloth can be difficult to detect. It comes complete with ultrasonic transmitter and receiver
module.
Procedure:

1. Follow the circuit diagram and make the connections as shown in the image given using
TinkerCad software.

Connections:

Components

a. Microcontroller Arduino Uno R3


b. Ultrasonic Distance Sensor
c. Breadboard Small

The Ultrasonic sensor has four terminals - +5V, Trigger, Echo, and GND connected as follows −

• Connect the +5V pin to +5v on your Arduino board.

• Connect Trigger to digital pin 7 on your Arduino board.

• Connect Echo to digital pin 6 on your Arduino board.

• Connect GND with GND on Arduino.


2. Type the text code given.

Text Code:

3. Run the simulation (make sure no error detection).


4. Show the result.
Result

*click at the ultrasonic Distance sensor, the adjustment controller will pop up. Adjust the controller and
see the result at the serial monitor.

ACTIVITY C: Temperature sensor

Operation and uses:

The Temperature Sensor LM35 series are precision integrated-circuit temperature devices with
an output voltage linearly proportional to the Centigrade temperature.

The LM35 device has an advantage over linear temperature sensors calibrated in Kelvin, as the
user is not required to subtract a large constant voltage from the output to obtain convenient
Centigrade scaling. The LM35 device does not require any external calibration or trimming to
provide typical accuracies of ±¼°C at room temperature and ±¾°C over a full −55°C to 150°C
temperature range.

Procedure:

1. Follow the circuit diagram and make the connections as shown in the image given using
TinkerCad software.
Connections:

Components

a. Microcontroller Arduino Uno R3


b. LM35 sensor
c. Breadboard Small

LM35 sensor has three terminals - Vs, Vout and GND. We will connect the sensor as follows −

• Connect the +Vs to +5v on your Arduino board.


• Connect Vout to Analog0 or A0 on Arduino board.
• Connect GND with GND on Arduino.
The Analog to Digital Converter (ADC) converts analog values into a digital approximation based
on the formula ADC Value = sample * 1024 / reference voltage (+5v). So with a +5 volt reference,
the digital approximation will be equal to input voltage * 205.

2. Type the text code given.


Text Code:

3. Run the simulation (make sure no error detection).


4. Show the result.

Result:

*click at the LM35 sensor, the adjustment controller will pop up. Adjust the controller and see the result
at the serial monitor.
ACTIVITY D: Button input

Button input
In the Arduino Button tutorial you are going to learn about interfacing the button with
Arduino using the Arduino digitalRead function. The buttons are very easy to use with
Arduino but you have to take care of few things like using the pull up resistor or using the
pull down resistor that I am going to explain in this tutorial. Without these things, the
button will behave erratically.
We will first simply connect the button with Arduino and will observe the unusual behavior
of the button. Then I will explain to you when is happening and we will overcome this
problem by using either the external Pull up or Pull down resistor or internal Pull up
resistor of the Arduino.
Then we will follow a more practical example and will make the LED high on pressing the
button two times and the LED will go LOW on pressing the button one time.
Procedure:

1. Follow the circuit diagram and make the connections as shown in the image given using
TinkerCad software.

Connections:
Components

a. Microcontroller Arduino Uno R3


b. PushButton
c. Led
d. 10k resistor
e. Breadboard Small

2. Type the text code given.

Text Code:

3. Run the simulation (make sure no error detection).


4. Show the result.
Result:

*Press the switch button, the LED light will OFF (0) & release the switch button and LED light will
ON (1). See the result at the serial monitor.

Conclusion :

You might also like