Sensors and Actuator
Understand networking theories and concepts, such as OSI model, TCP/IP protocols, and subnetting
Build logical and abstract thinking
Size: 2.66 MB
Language: en
Added: Mar 05, 2025
Slides: 70 pages
Slide Content
Internet of Things
Sensors & Actuators
Abdallah El Ghamry
IoT Applications
Things
Internet of Things
Internet of Things
▪TheInternetofThings(IoT)representsthenetworkofphysicalobjects
“Things”thatareintegratedwithsensors,softwareandothertechnologies
forthepurposeofexchangingdatawithotherdevicesontheInternet.
Sensors
Temperature
and Humidity
PIR Motion
Detection
Microphone
Sound Detection
Gas/Smoke
Sensor
Photoresistor
CdS Sensor
Ultrasonic
Sensor
IR Obstacle
Avoidance
Heart Rate
Sensor (ECG)
Actuators
▪Sensorsturnaphysicalinputintoanelectricaloutput,while
actuatorsdotheopposite.
▪Actuatorstakeelectricalsignalsfromcontrolmodulesandturnthem
intophysicaloutputs.
LEDs Buzzer DC Fan Servo Motor
Actuators: Servo Motor
▪Aservomotorisanelectricaldevicewhichcanpushorrotatean
objectwithgreatprecision.
Actuators: Servo Motor
▪TheHBE-ROBONOVAAI3isanintelligentrobotwithanMR-C3024
controllerboardcapableofcontrolling32servomotorssimultaneously.
Power Supply Pins
▪TheArduinoUnoprovidesbotha5V,anda3.3Vpowersupply.
Arduino IDE
▪TheArduinoIDEenablesyoutowriteandeditcodeandconvertthiscode
intoinstructionsthatArduinohardwareunderstands.
Downloading Arduino IDE
▪Gotohttps://www.arduino.cc/en/softwarewebsite.
Downloading Arduino IDE
▪Clickthe“JustDownload”option.
Installing Arduino IDE
Installing Arduino IDE
Installing Arduino IDE
Installing Arduino IDE
Arduino Sketches
▪A sketchis the name that Arduino uses for a program.
voidsetup(){
// put your setup code here, to run once:
}
voidloop(){
// put your main code here, to run repeatedly:
}
Turning on an LED: Steps
1.Connectbreadboardpower(+)andground(-)railstoArduino5V
andground(GND),respectively.
Turning on an LED: Steps
2.PlugtheLEDintotwodifferentbreadboardrows.
Turning on an LED: Steps
3.Thecathode(shorterleg)connectstoonelegofaresistorof330Ω,
andtheotherresistorlegtotheground.
Turning on an LED: Steps
4.WireuptheLEDanode(longerleg)tothepower.
Your First Arduino Project: Blinking an LED
▪TurnanLEDonandoffeverysecond.
Your First Arduino Project: Circuit
▪TurnanLEDonandoffeverysecond.
Your First Arduino Project: Steps
1.Connectbreadboardpower(+)andground(-)railstoArduino5V
andground(GND),respectively.
Your First Arduino Project: Steps
2.PlugtheLEDintotwodifferentbreadboardrows.
Your First Arduino Project: Steps
3.Thecathode(shorterleg)connectstoonelegofaresistorof330Ω,
andtheotherresistorlegtotheground.
Your First Arduino Project: Steps
4.WireuptheLEDanode(longerleg)toArduinopin13.
Your First Arduino Project: Schematic
Your First Arduino Project: Blink
YoumayalsoloaditfromFile→Examples→01.Basics→Blink
Your First Arduino Project: Code
// Turns an LED on for one second, then off for one second, repeatedly .
// The setup function runs once when you press reset or power the board
voidsetup(){
// Initialize digital pin LED_BUILTIN (13) as an output.
pinMode(LED_BUILTIN, OUTPUT);
}
// The loop function runs over and over again forever
voidloop(){
digitalWrite(LED_BUILTIN, HIGH); // Turn the LED on
delay(1000); // Wait for a second
digitalWrite(LED_BUILTIN, LOW); // Turn the LED off
delay(1000); // Wait for a second
}
Your First Arduino Project: Arduino AVR Boards
GotoTools→Board,andselectyourboard.
Your First Arduino Project: Port
GotoTools→Port,andselecttheportoftheArduinoboard.
Your First Arduino Project: Verify a Sketch
ClicktheVerifybuttontotrycompilingthesketchandcheckforerrors.
Your First Arduino Project: Upload a Sketch
ClicktheUploadbuttontoprogramtheboardwiththesketch.
Your First Arduino Project: Discussion
▪ThefirstthingyoudoistoinitializeLED_BUILTINpinasanoutputpin
withtheline:
pinMode(LED_BUILTIN, OUTPUT);
▪Inthemainloop,youturntheLEDonwiththeline:
digitalWrite(LED_BUILTIN, HIGH);
▪Thenyouturnitoffwiththeline:
digitalWrite(LED_BUILTIN, LOW);
Your First Arduino Project: Discussion
▪Thedelay()causestheArduinotowaitforthespecifiednumberof
millisecondsbeforecontinuingontothenextline.
▪Thereare1000millisecondsinasecond,sothefollowinglinecreatesa
delayofonesecond.
delay(1000);
▪Constantsareusedtomaketheprogramseasiertoread.
▪TheconstantLED_BUILTINisthenumberofthepintowhichtheon-
boardLEDisconnected.
▪MostboardshavethisLEDconnectedtodigitalpin13.
Your First Arduino Project: Alternative Code
// Turns an LED on for one second, then off for one second, repeatedly .
// The setup function runs once when you press reset or power the board
voidsetup(){
// Initialize digital pin 13 as an output.
pinMode(13, OUTPUT);
}
// The loop function runs over and over again forever
voidloop(){
digitalWrite(13, HIGH); // Turn the LED on
delay(1000); // Wait for a second
digitalWrite(13, LOW); // Turn the LED off
delay(1000); // Wait for a second
}
Photoresistor: Code
intphotoresistor = 0; // A variable holds the value of photoresistor
intthreshold = 750; //
voidsetup()
{
Serial.begin(9600); // Start a serial connection with the computer
pinMode(13, OUTPUT); // Set pin 13 as an output pin
}
voidloop()
{
photoresistor = analogRead(A0); // Read the brightness of the LED
Serial.println(photoresistor); // Print the value of photoresistor
// If the photoresistor value < threshold turn the light on, otherwise turn it off
if(photoresistor < threshold)
digitalWrite(13, HIGH); // Turn on the LED
else
digitalWrite(13, LOW); // Turn off the LED
delay(100); // Short delay
}
ADC vs. DAC
Read Analog Voltage
▪Themicrocontrolleroftheboardhasacircuitinsidecalledan
analog-to-digitalconverter(ADC)thatreadsthischangingvoltage
andconvertsittoanumberbetween0and1023.
▪TheADCinArduinois10-bit.
0000000000 0V
1111111111 5V
Read Analog Voltage
▪TheanalogRead()returnsanumberbetween0and1023thatis
proportionaltotheamountofvoltagebeingappliedtothepin.
▪Toscalethenumbersbetween0and5,divide5by1023andmultiplythat
bysensorValue:
voltage=sensorValue*(5.0/1023.0);
Closed-Loop vs. Open-Loop Control Systems
▪Anopen-loopcontrolsystemdoesnotmonitortheoutputtodetermine
whatadjustmentstomaketotheinput.
▪Forexample,whenusingaclothesdryer,youmightsetthetimeronthe
dryertorunthedryingcycleforonehour.
▪Attheendofthehour,thedryerwillstop.
▪Thelevelofdrynessoftheclotheswillvarydependingupontheirlevelof
wetnessatthebeginningofthecycle.
Controller ProcessInput Output
Closed-Loop vs. Open-Loop Control Systems
▪Inaclosed-loopcontrolsystem,theoutputismeasuredtodetermine
whetheritisthedesiredoutputandadjusttheinputasappropriate.
▪Forexample,iftheclothesdryerisequippedwithmoisturesensors,the
inputmaybealevelofdrynessthatadjuststhecyclebyextendingthe
dryingtimeuntilthesensorsindicatetheclothesaredried.
Controller Process
Sensor
Input Output
Error