Professional Documents
Culture Documents
The Basics
There are 3 main
categories of
components
MCU /
Sensor Microcontroller /
ESP32 Actuator
09/10/2023 2
09/10/2023
NOT THIS MCU! 3
Sensor Actuator
(Provides data to MCU) Microcontroller (Make an action)
(Compute and Make
decision)
Sensor (NON EXHAUSTIVE LIST)
• Ultrasonic
• Passive Infrared
• Temperature
• Humidity
• Light intensity
• PH meter
09/10/2023 5
Ultrasonic sensor
(Distance measurement)
09/10/2023 6
Passive Infrared
(PIR)
(Movement
monitoring)
09/10/2023 7
Temperature sensor
(Temperature measuring)
Ambient Light Sensor
(Light intensity)
09/10/2023 9
Sensor • They come in different shapes and sizes!
• Different shape, different use cases
• Example : Temperature sensor for measuring surface
temperature is different than for measuring
liquid/ambient temperature
09/10/2023 10
ALWAYS REFER
TO THE
DATASHEET!
Professional Moron 11
Datasheet example
09/10/2023 12
Actuator (Non
Exhaustive List)
• LED
• Servo motor
• Wireless module
09/10/2023 13
Actuators
• They make action based on
decision made by the MCU
• They can either : Light up,
Move, Send data or anything
• Creativity is the key, think
outside the box!
• Don’t be afraid to try things,
they have safeguards.
• Worst case : you break a IDR
50.000 worth of electric
component but you get an
important lesson
09/10/2023 14
Simulate things
(Wokwi.com)
Worksheet
09/10/2023 15
Go to Wokwi.com • Create a new ESP32 Project
• Press the blue (+) button
09/10/2023 16
Parts! Finally!
09/10/2023 17
Simple thing first
09/10/2023 18
No Datasheet?
But how do I wire
it?
09/10/2023 19
Manage your
wirings! (Good
practice)
09/10/2023 20
Less overlapping wires = BETTER
09/10/2023 23
Now the fun part
begins
Programming
09/10/2023 24
#define <variable name> <pin number>
Setup() Defining PIN will make it easier down the road,
if you change the connected PIN of a component,
all you have to change is the define
09/10/2023 25
Setup() • Now, each of the PINs
connected to LED have to be
declared as OUTPUT
• If you are using 5 PINs to
power 5 LEDs then you have
to set all the pinModes for
all the PINs (this example
only shows 3 pinMode calls,
but you should make 5
pinMode calls)
09/10/2023 26
Loop()
09/10/2023 27
Now let’s modify it so the
LEDs are turning on in
sequence, then turn it all OFF
09/10/2023 28
Continued
09/10/2023 29
Exercise