Uploaded by 25ddt21f1072

PRACTICAL WORK1 F1072

advertisement
COURSE CODE:
DFN40312
COURSE NAME:
EMBEDDED INTERNET OF THINGS
ASSESSMENT:
PRACTICAL WORK 1
CLASS:
DDT4IS2
PREPARED FOR:
MADAM NOR FAIZAH BINTI ZAILANI
PREPARED BY:
DIVISHA JEGATHEES
25DDT21F1072
NAME
DIVISHA JEGATHEES
REGISTRATION NO
25DDT21F1072
DATE
27.02.2023
CLASS
DDT4IS2
CODE/SUBJECT
ASSESSMENT
LECTURER
MARKS
DFN40312- EMBEDDED INTERNET OF
THINGS
PRACTICAL WORK 1
MADAM NOR FAIZAH BINTI ZAILANI
100
CLO 1: Construct a model of IoT solutions using Embedded IoT platforms (P4, PLO3)
TOPIC
2.2 : Assemble microcontroller programs with variety of components
2.3 : Perform microcontroller configuration to monitor a variety of sensor / inputs
DURATION: 3 HOURS
INSTRUCTION: ANSWER ALL THE QUESTIONS
Objectives

Setup the equipment, software, and services that enable IoT systems

Construct a simple hardware connection and perform compiling, uploading and
testing successfully.
Equipment:
1.
2.
3.
4.
5.
6.
ESP32 Module Board
Jumper wire
Breadboard
Traffic light module
Push Button
PC installed with Arduino IDE
PROCEDURE:
PART A : LED blinking
1. Assemble the circuit referring to Figure 1.
Circuit connection Traffic Light Module to ESP32
R  D5
GND GND
Figure 1
2. Sketch source code
//**** LED Blinking *******
const int ledPin = 5;
void setup() {
// setup pin 5 as a digital output pin
pinMode (ledPin, OUTPUT);
}
void loop() {
digitalWrite (ledPin, HIGH); // turn on the LED
delay(500);
// wait for half a second or 500 milliseconds
digitalWrite (ledPin, LOW); // turn off the LED
delay(500);
// wait for half a second or 500 milliseconds
}
3. Upload sketch to ESP32. Observe and record the output.
4. Write coding for the system using this condition:
a. The system has THREE (3) output (LED1, LED2 &LED3). LED1 is red LED
while LED2 is green LED and LED3 is yellow LED.
b. Develop running light LED starting sequence from red LED and follow by
yellow LED and green LED. Use 1000ms delay for each sequence.
PART B : Control Digital Output using push button
1. Assemble the circuit referring to Figure 2.
CIRCUIT CONNECTION TO ESP32 BOARD

Traffic light module
RD4
GNDGND

Push button module
VCC 3.3V
GNDGND
OUTD5
Figure 2
2. Sketch source code as following.
const int buttonPin =5; // the number of the pushbutton pin
const int ledPin = 4; // the number of the LED pin
// variable for storing the pushbutton status
int buttonState = 0;
void setup() {
Serial.begin(9600);
// initialize the pushbutton pin as an input
pinMode(buttonPin, INPUT);
// initialize the LED pin as an output
pinMode(ledPin, OUTPUT);
}
void loop() {
// read the state of the pushbutton value
buttonState = digitalRead(buttonPin);
Serial.println(buttonState);
// check if the pushbutton is pressed.
// if it is, the buttonState is HIGH
if (buttonState == HIGH) {
// turn LED on
digitalWrite(ledPin, HIGH);
} else {
// turn LED off
digitalWrite(ledPin, LOW);
}
}
3. Upload sketch to ESP32. Observe and record the output.
4. Write coding for the system using this condition:
a) The system has ONE (1) input (SW1).
b) The system has THREE (3) output (LED1, LED2 &LED3). LED1 is red LED while
LED2 is green LED and LED3 is yellow LED.
c) Functional algorithm:
i)
when SW1 is LOW condition, all LEDs work as traffic lights starting with a
sequence of yellow LEDs ON for 500ms while red and green will OFF.
ii)
When SW1 is HIGH condition, only red LED will light ON.
iii)
Display output to the serial monitor that shows status of push button and
LED.
5. Observe and record the output.
Part A(Source Code)
Part B(Source Code)
Link For Output Video:
https://drive.google.com/file/d/1FEctXaFXn9pfxRQN_nW9uxcf18ukfdGg/view?usp=share_li
nk
Download