SlideShare a Scribd company logo
Introduction to Arduino
Microcontroller
Prepared by:
Md. Asaduzzaman
Dept of ICT, MBSTU
Prepared by- Md Asaduzzaman , Dept of ICT,MBSTU
1
Contents
 What is Microcontroller?
 What is Arduino?
 Types of Arduino?
 Installation process
 Types Sensors?
- Digital, Analog sensors.
 Motor control
 Coding structure and examples with C/C++ Library File?
1. Data types and operators.
2. What is “Function”?
3. Control statements [if, if… else, switch case.].
4. Loop statements[while, for, do… while.].
5. Common functions.
Prepared by- Md Asaduzzaman , Dept of ICT,MBSTU
2
What is a
Microcontroller ?
Prepared by- Md Asaduzzaman , Dept of ICT,MBSTU
3
Microcontroller
 It is a micro-computer. As any
computer it has internal CPU, RAM,IOs interface.
 Microcontroller = internally (CPU+RAM+IO interface)
integrated device
 It is used for control purposes, and
for data analysis.
 Must Need a Programmer.
 Work as, both Master or Slave device.
 Famous microcontroller
manufacturers are MicroChip,
Atmel,Atmega, Intel,IBM etc.
Prepared by- Md Asaduzzaman , Dept of ICT,MBSTU
4
Microcontroller Programmer
 Hardware :
PIC Programmer, Pocket AVR Programmer etc.
 Software : (AVR,AVRISP,USBISP,USBASP) .
Prepared by- Md Asaduzzaman , Dept of ICT,MBSTU
5
USB PIC Microcontroller
Programmer
What is the difference
between Microcomputer
and Microcontroller ?
Prepared by- Md Asaduzzaman , Dept of ICT,MBSTU
6
What is Arduino Microcontroller ??
 It is Open Source (Hardware + Software) and single board microcontroller.
 Work as, both Master or Slave device.
 Arduino = internally CPU+RAM+IO interfaces + programmer
(AVR,AVRISP,USBISP,USBASP) .
 In 2005, a project was initiated to make a device for controlling
student-built interactive design projects that was less expensive
than other prototyping systems available at the time.
 Founders Massimo Banzi and David Cuartielles named the project
after Arduin of Ivrea and began producing boards in a small factory
located in Ivrea.
Prepared by- Md Asaduzzaman , Dept of ICT,MBSTU
7
General Structure of Arduino ?
Prepared by- Md Asaduzzaman , Dept of ICT,MBSTU
8
Arduino Specification
 Microcontroller ATmega328
 Operating Voltage 5V and 3.3 V
 Baud Rate : 9600, 14400, 19200, 28800, 38400, 57600,
or 115200 bps.
 Input Voltage (recommended) 7-12V
 Input Voltage (limits) 6-20V
 Digital I/O Pins 14 (of which 6 provide PWM output)
 Analog Input Pins 6
 DC Current per I/O Pin 40 mA
 DC Current for 3.3V Pin50 mA
 Flash Memory 32 KB (ATmega328) of which 0.5 KB used
by Bootloader
 SRAM 2 KB (ATmega328)
 EEPROM 1 KB (ATmega328)
 Clock Speed 16 MHz
 Other Prototyping Platform:
 Raspberry pie
 Beagle board
 Panda board
 Cotton candy
 Cubie Board
 APC Rock
 Hackberry
 Gooseberry
Prepared by- Md Asaduzzaman , Dept of ICT,MBSTU
9
Types of Arduino ?
Prepared by- Md Asaduzzaman , Dept of ICT,MBSTU
10
Specification of different Types of Arduino
-01
Prepared by- Md Asaduzzaman , Dept of ICT,MBSTU
11
Specification of different Types of Arduino
-02
Prepared by- Md Asaduzzaman , Dept of ICT,MBSTU
12
Arduino Based Sensor
Prepared by- Md Asaduzzaman , Dept of ICT,MBSTU
13
Types of Sensor
 Two types:
1. Digital Sensor
2. Analog Sensor
Prepared by- Md Asaduzzaman , Dept of ICT,MBSTU
14
Frequently Used Sensor
 Humidity sensor (DHT22) - Digital Sensor
 Temperature sensor (LM35) - Analog Sensor
 Water detector sensor (Simple Water Trigger) - Digital Sensor
 PIR SENSOR - Digital Sensor
 ULTRASONIC SENSOR - Digital Sensor
 Sound Sensor - Digital Sensor
 GPS
Prepared by- Md Asaduzzaman , Dept of ICT,MBSTU
15
Humidity Sensor (DHT22) –Digital Sensor
 Technical Details
Power − 3-5V
Max Current − 2.5mA
Humidity − 0-100%, 2-5% accuracy
Temperature − 40 to 80°C, ±0.5°C accuracy
Prepared by- Md Asaduzzaman , Dept of ICT,MBSTU
16
Temperature Sensor (LM35) Analog Sensor
Technical Specifications:
 Calibrated directly in Celsius (Centigrade)
 Linear + 10-mV/°C scale factor.0.5°C ensured
accuracy (at 25°C)
 Rated for full −55°C to 150°C range
 Suitable for remote applications
Prepared by- Md Asaduzzaman , Dept of ICT,MBSTU
17
Water Sensor (Digital Sensor)
Technical Specification:
 Water sensor has three terminals –
S,Vout(+), and GND (-).
Connect the sensor as follows −
 Connect the +Vs to +5v on your Arduino
board.
 Connect S to digital pin number 8 on Arduino
board.
 Connect GND with GND on Arduino.
Prepared by- Md Asaduzzaman , Dept of ICT,MBSTU
18
PIR (Pyroelectric/Passive Infrared
Radiation) Sensor (Digital Sensor)
Technical Specification:
 PIR sensor has three terminals : Vcc, OUT
and GND.
Connect the sensor as follows −
 Connect the +Vcc to +5v on Arduino board.
 Connect OUT to digital pin on Arduino
board.
 Connect GND with GND on Arduino.
Prepared by- Md Asaduzzaman , Dept of ICT,MBSTU
19
Ultrasonic Sensor (HC-SR04) - Digital
Sensor
 Technical Specifications
 Power Supply − +5V DC
 Quiescent Current − <2mA
 Working Current − 15mA
 Effectual Angle − <15°
 Ranging Distance − 2cm – 400 cm/1″ – 13ft
 Resolution − 0.3 cm
 Measuring Angle − 30 degree
 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.Prepared by- Md Asaduzzaman , Dept of ICT,MBSTU
20
Sound Detection Sensor (Digital Sensor)
Prepared by- Md Asaduzzaman , Dept of ICT,MBSTU
21
Control the different
type of motor with
Arduino
Prepared by- Md Asaduzzaman , Dept of ICT,MBSTU
22
Types of Motor ??
 There are three different type of motors −
 DC motor
 Servo motor
 Stepper motor DC Motor
Servo motor
Stepper motor
Prepared by- Md Asaduzzaman , Dept of ICT,MBSTU
23
Necessary Things to done a Project with
Motor
 Motor Driver : To control the direction of the spin of DC motor, without
interchanging the leads, you can use a circuit called an H-Bridge(Motor Driver).
An H-bridge is an electronic circuit that can drive the motor in both directions.
 Example : L298, L293 ,ESC etc.
Prepared by- Md Asaduzzaman , Dept of ICT,MBSTU
24
L298 Motor Driver
Arduino Installation
 First you must have your Arduino board and a USB cable.
 Download Arduino IDE and driver.
 IDE Link: ARDUINO 1.8.5 : https://www.arduino.cc/en/Main/Software
(go for windows installer) Download and Install it.
 Driver Link: https://www.dropbox.com/s/a1d4837hbfylipb/windows-driver-
installer.exe?dl=0 Download and Install it.
Prepared by- Md Asaduzzaman , Dept of ICT,MBSTU
25
Run on IDE
Prepared by- Md Asaduzzaman , Dept of ICT,MBSTU
26
Basic Structure of a Sketch
 Open/Create a Sketch and Save it with .ino extension.
Prepared by- Md Asaduzzaman , Dept of ICT,MBSTU
27
Open an Example Sketch
Prepared by- Md Asaduzzaman , Dept of ICT,MBSTU
28
Select a Board
Prepared by- Md Asaduzzaman , Dept of ICT,MBSTU
29
Select a Communication port
Prepared by- Md Asaduzzaman , Dept of ICT,MBSTU
30
Upload a Sketch
A - used to check compile error.
B - Upload the program (Sketch).
C - Create new Sketch.
D - Open a Sketch.
E - Save a Sketch.
F – Serial monitor is Used to Visualize of transformation of serial data.
Prepared by- Md Asaduzzaman , Dept of ICT,MBSTU
31
Arduino
Programming with
C/C++ Library File
Prepared by- Md Asaduzzaman , Dept of ICT,MBSTU
32
Life Cycle of Arduino Sketch
Prepared by- Md Asaduzzaman , Dept of ICT,MBSTU
33
Input and Output Function
 pinMode(Pin_no, Mode);
 Mode= Input/Output on Analog or Digital pin
 digitalRead(D_Pin_no);
 digitalWrite(D_Pin_no, High/Low);
 delay(time_ms);
 other functions:
 analogRead(A_Pin_no);
 analogWrite(A_pin_no, PWM_input); //PWM.
Prepared by- Md Asaduzzaman , Dept of ICT,MBSTU
34
PWM (Pulse Width Modulation)
Prepared by- Md Asaduzzaman , Dept of ICT,MBSTU
35
Data Type : Like as C/C++
Prepared by- Md Asaduzzaman , Dept of ICT,MBSTU
36
Operators : Like as C/C++
 - Math operators: [+,-,*,/,%,^,++]
 - Logic operators: [==, !=, &&, || ]
 - Comparison operators: [==, >, <, !=, <=, >=]
 Compound Operators:
++ (increment)
-- (decrement)
+= (compound addition)
-= (compound subtraction)
*= (compound multiplication)
/= (compound division)
 - Other : ; = Semicolon, {} = curly braces, // = single line comment,
/*Multi-line comments*/
Prepared by- Md Asaduzzaman , Dept of ICT,MBSTU
37
Control Statement: Like as C/C++
 If(condition) {…………}
 If(condition) {………….} else {…………..}
 If (condition) {…} else if (condition) {….} else {………}
 switch (var) {
case 1:
//do something when var equals 1
break;
case 2:
//do something when var equals 2
break;
default:
// if nothing else matches, do the default
// default is optional
}
Prepared by- Md Asaduzzaman , Dept of ICT,MBSTU
38
Loop Statement: Like as C/C++
 Do… while:
do
{
Statements;
break;
}
while(condition); // the statements are run at least once.
 While:
While(condition)
{statements; break; }
 for
for (int i=0; i <= val; i++){
statements;
break;
}
Prepared by- Md Asaduzzaman , Dept of ICT,MBSTU
39
Basic Structure of a Simple Project: 01
Blinking LED (Send a Digital Serial Write command to a Slave (Sensors,
LEDs, Motors etc.))
void setup() //the setup function runs once when you press reset or power the board.
{
pinMode(3, OUTPUT); // initialize digital pin 3 as an output.
}
void loop() // the loop function runs over and over again forever.
{
digitalWrite(3, HIGH); // turn the LED on (HIGH is the voltage level).
delay(1000); // wait for a second.
digitalWrite(3, LOW); // turn the LED off by making the voltage LOW.
delay(1000); // wait for a second.
}
Prepared by- Md Asaduzzaman , Dept of ICT,MBSTU
40
Circuit Diagram of Project: 01
Prepared by- Md Asaduzzaman , Dept of ICT,MBSTU
41
Basic Structure of a Simple Project: 02
Digital Serial Data Reading (Receive a command from a
Slave (Sensors, LEDs, Motors etc.))
int pushButton = 2; // digital pin 2 has a pushbutton attached to it. Give it a name:
void setup()
{
Serial.begin(9600); // initialize serial communication at 9600 bits per second:
pinMode(pushButton, INPUT); // make the pushbutton's pin an input:
}
void loop()
{
int buttonState = digitalRead(pushButton); // read the input pin:
Serial.println(buttonState); // print out the state of the button:
delay(1); // delay in between reads for stability
}
Prepared by- Md Asaduzzaman , Dept of ICT,MBSTU
42
Basic Structure of a Simple Project: 03
Analog Serial Data Reading (Receive a command from
a Slave ((Sensors, LEDs, Motors etc.))
void setup()
{
Serial.begin(9600); // initialize serial communication at 9600 bits per second:
}
void loop()
{
int sensorValue = analogRead(A0); // read the input on analog pin 0:
float voltage = sensorValue*(5.0/1023.0);
// Convert the analog reading(0-1023) to a voltage(0-5V):
Serial.println(voltage); // print out the value you read:
}
Prepared by- Md Asaduzzaman , Dept of ICT,MBSTU
43
Circuit diagram of Project- 03
Potentiometer
Prepared by- Md Asaduzzaman , Dept of ICT,MBSTU
44
Basic Structure of a Simple Project: 04
(Send a Analog Serial Write PWM command to a
Slave (Sensors, LEDs, Motors etc.))
void setup()
{
Serial.begin(9600); // initialize serial communication at 9600 bits per second:
}
void loop()
{
int Value = random(0,1023);
//set a analog serial data (which goes from 0 - 1023) to a voltage (0 - 5V):
float voltage = Value * (5.0 / 1023.0);
analogWrite(A1,voltage); // write the input on analog pin 1:
Serial.println(voltage); // print out the value you write:
}
Prepared by- Md Asaduzzaman , Dept of ICT,MBSTU
45
Can anyone tell us the Sketch
(code) of merging the idea of
Project -01,02,03 and Project -
04 ??
Prepared by- Md Asaduzzaman , Dept of ICT,MBSTU
46
Merge circuit Diagram of Project -03 and
Project -04
Prepared by- Md Asaduzzaman , Dept of ICT,MBSTU
47
Test Our Skills : (PWM) Anyone Please explain Where PWM is used?
int led = 3,brightness = 0,fadeAmount = 5;
void setup()
{
pinMode(led, OUTPUT);
}
void loop()
{
analogWrite(led, brightness);
brightness = brightness + fadeAmount;
if (brightness == 0 || brightness == 255)
{
fadeAmount = -fadeAmount ;
}
delay(30);
}
Prepared by- Md Asaduzzaman , Dept of ICT,MBSTU
48
Basic Project -05 Control the Spin of
Motor
const int pwm = 10 ;
const int in_1 = 9 ;
const int in_2 = 8 ;
void setup()
{
pinMode(pwm,OUTPUT) ;
pinMode(in_1,OUTPUT) ;
pinMode(in_2,OUTPUT) ;
}
void loop()
{
digitalWrite(in_1,HIGH) ;
digitalWrite(in_2,LOW) ;
analogWrite(pwm,255) ; //Clockwise for 3 secs
delay(3000) ;
digitalWrite(in_1,LOW) ;
digitalWrite(in_2,HIGH) ;
delay(3000) ; //Anti-Clockwise for 3 secs
}
Prepared by- Md Asaduzzaman , Dept of ICT,MBSTU
49
Basic Project -05 Control the Spin of
Motor Circuit diagram
Prepared by- Md Asaduzzaman , Dept of ICT,MBSTU
50
Project -06 : A Simple Home Security
System
 Basic Idea : To build an human detection System for your Home using Arduino on
220v AC.
 Instruments:
 Arduino
 PIR Sensor.
 Relay Module (The relay board works on 220V AC .So keep necessary safety measurements.).
 LED and Buzzer.
 Motor.
 Jumper Wire and Breadboard.
 L298 Motor Driver.
Prepared by- Md Asaduzzaman , Dept of ICT,MBSTU
51
Project -06 :Smart home Security Circuit
Diagram
Prepared by- Md Asaduzzaman , Dept of ICT,MBSTU
52
Project-06: Sketch of Home Security
System
int LED = 3;
int PIR = 2;
int Buzzer = 7;
void setup()
{
pinMode(LED, OUTPUT);
pinMode(Buzzer, OUTPUT);
pinMode(PIR, INPUT);
}
Prepared by- Md Asaduzzaman , Dept of ICT,MBSTU
53
void loop() {
int value =
digitalRead(PIR);
if (value == HIGH){
digitalWrite(LED, HIGH);
digitalWrite(Buzzer,
HIGH);
}
else {
digitalWrite(LED, LOW);
digitalWrite(Buzzer,
LOW);
}
}
Project -07:Clap controlled Smart home Circuit
Diagram
Prepared by- Md Asaduzzaman , Dept of ICT,MBSTU
54
Video Tutorial of Building the Clap Control
Prepared by- Md Asaduzzaman , Dept of ICT,MBSTU
55
Project References
 http://www.instructables.com/technology/arduino/ for project idea.
 https://playground.arduino.cc/Projects/Ideas .
 https://codebender.cc/home for project code Must need Firefox/chrome.
 https://github.com for project code.
 https://youtube.com for tutorial.
 https://learn.sparkfun.com/tutorials for tutorial.
 https://www.allaboutcircuits.com/projects/category/arduino/ for tutorial.
 https://diyhacking.com/diy-projects/arduino-projects/ for project idea.
 http://mertarduinotutorial.blogspot.com for tutorial.
 Arduino for Dummies by- John Nussey.
 Arduino Programming by- Simon Monk.
Prepared by- Md Asaduzzaman , Dept of ICT,MBSTU
56
Any Question ??
Prepared by- Md Asaduzzaman , Dept of ICT,MBSTU
57
Thank You
Prepared by- Md Asaduzzaman , Dept of ICT,MBSTU
58

More Related Content

What's hot (20)

RISC-V Introduction
RISC-V IntroductionRISC-V Introduction
RISC-V Introduction
Yi-Hsiu Hsu
 
Lpc1768
Lpc1768Lpc1768
Lpc1768
Krishnamoorthy Upadhya
 
Jtag presentation
Jtag presentationJtag presentation
Jtag presentation
klinetik
 
Arm instruction set
Arm instruction setArm instruction set
Arm instruction set
PriyangaKR1
 
History of microprocessors copy
History of microprocessors   copyHistory of microprocessors   copy
History of microprocessors copy
yvonne katsande
 
Pbf retrospective payment social security contributions
Pbf   retrospective payment social security contributionsPbf   retrospective payment social security contributions
Pbf retrospective payment social security contributions
mfcsmalta
 
Build your career in physical ASIC design
Build your career in physical ASIC designBuild your career in physical ASIC design
Build your career in physical ASIC design
Mohammed Essam Abd El Samee
 
6 STM32's USART.ppt
6 STM32's USART.ppt6 STM32's USART.ppt
6 STM32's USART.ppt
MdRayhanTanvir
 
Verification Strategy for PCI-Express
Verification Strategy for PCI-ExpressVerification Strategy for PCI-Express
Verification Strategy for PCI-Express
DVClub
 
Salient featurs of 80386
Salient featurs of 80386Salient featurs of 80386
Salient featurs of 80386
aviban
 
What is JTAG?
What is JTAG?What is JTAG?
What is JTAG?
killerdolton
 
SISTec Microelectronics VLSI design
SISTec Microelectronics VLSI designSISTec Microelectronics VLSI design
SISTec Microelectronics VLSI design
Dr. Ravi Mishra
 
Design and implementation of uart on soc
Design and implementation of uart on socDesign and implementation of uart on soc
Design and implementation of uart on soc
Ijrdt Journal
 
CMOS VLSI PROJECT || CMOS 3-Bit Binary to Square of the given Input || MULTIP...
CMOS VLSI PROJECT || CMOS 3-Bit Binary to Square of the given Input || MULTIP...CMOS VLSI PROJECT || CMOS 3-Bit Binary to Square of the given Input || MULTIP...
CMOS VLSI PROJECT || CMOS 3-Bit Binary to Square of the given Input || MULTIP...
rameshreddybattini
 
I2C Protocol
I2C ProtocolI2C Protocol
I2C Protocol
Sudhanshu Janwadkar
 
stepper motor
stepper motorstepper motor
stepper motor
Hiren Patel
 
Creating Your Own PCI Express System Using FPGAs: Embedded World 2010
Creating Your Own PCI Express System Using FPGAs: Embedded World 2010Creating Your Own PCI Express System Using FPGAs: Embedded World 2010
Creating Your Own PCI Express System Using FPGAs: Embedded World 2010
Altera Corporation
 
Lpc2148 user peripherals
Lpc2148 user peripheralsLpc2148 user peripherals
Lpc2148 user peripherals
fivesquare
 
ARM Processor Tutorial
ARM Processor Tutorial ARM Processor Tutorial
ARM Processor Tutorial
Embeddedcraft Craft
 
ASIC vs SOC vs FPGA
ASIC  vs SOC  vs FPGAASIC  vs SOC  vs FPGA
ASIC vs SOC vs FPGA
Verification Excellence
 
RISC-V Introduction
RISC-V IntroductionRISC-V Introduction
RISC-V Introduction
Yi-Hsiu Hsu
 
Jtag presentation
Jtag presentationJtag presentation
Jtag presentation
klinetik
 
Arm instruction set
Arm instruction setArm instruction set
Arm instruction set
PriyangaKR1
 
History of microprocessors copy
History of microprocessors   copyHistory of microprocessors   copy
History of microprocessors copy
yvonne katsande
 
Pbf retrospective payment social security contributions
Pbf   retrospective payment social security contributionsPbf   retrospective payment social security contributions
Pbf retrospective payment social security contributions
mfcsmalta
 
Verification Strategy for PCI-Express
Verification Strategy for PCI-ExpressVerification Strategy for PCI-Express
Verification Strategy for PCI-Express
DVClub
 
Salient featurs of 80386
Salient featurs of 80386Salient featurs of 80386
Salient featurs of 80386
aviban
 
SISTec Microelectronics VLSI design
SISTec Microelectronics VLSI designSISTec Microelectronics VLSI design
SISTec Microelectronics VLSI design
Dr. Ravi Mishra
 
Design and implementation of uart on soc
Design and implementation of uart on socDesign and implementation of uart on soc
Design and implementation of uart on soc
Ijrdt Journal
 
CMOS VLSI PROJECT || CMOS 3-Bit Binary to Square of the given Input || MULTIP...
CMOS VLSI PROJECT || CMOS 3-Bit Binary to Square of the given Input || MULTIP...CMOS VLSI PROJECT || CMOS 3-Bit Binary to Square of the given Input || MULTIP...
CMOS VLSI PROJECT || CMOS 3-Bit Binary to Square of the given Input || MULTIP...
rameshreddybattini
 
Creating Your Own PCI Express System Using FPGAs: Embedded World 2010
Creating Your Own PCI Express System Using FPGAs: Embedded World 2010Creating Your Own PCI Express System Using FPGAs: Embedded World 2010
Creating Your Own PCI Express System Using FPGAs: Embedded World 2010
Altera Corporation
 
Lpc2148 user peripherals
Lpc2148 user peripheralsLpc2148 user peripherals
Lpc2148 user peripherals
fivesquare
 

Similar to Arduino tutorial A to Z (20)

introductiontoarduino-111120102058-phpapp02.pdf
introductiontoarduino-111120102058-phpapp02.pdfintroductiontoarduino-111120102058-phpapp02.pdf
introductiontoarduino-111120102058-phpapp02.pdf
HebaEng
 
Chapter 5 Arduino Microcontroller Systems .pptx
Chapter 5 Arduino Microcontroller Systems .pptxChapter 5 Arduino Microcontroller Systems .pptx
Chapter 5 Arduino Microcontroller Systems .pptx
khgh7
 
Ardui no
Ardui no Ardui no
Ardui no
Amol Sakhalkar
 
arduinoworkshop-160204051621.pdf
arduinoworkshop-160204051621.pdfarduinoworkshop-160204051621.pdf
arduinoworkshop-160204051621.pdf
AbdErrezakChahoub
 
01 Intro to the Arduino and it's basics.ppt
01 Intro to the Arduino and it's basics.ppt01 Intro to the Arduino and it's basics.ppt
01 Intro to the Arduino and it's basics.ppt
pindi2197
 
Starting with Arduino
Starting with Arduino Starting with Arduino
Starting with Arduino
MajdyShamasneh
 
Arduino Programming Basic
Arduino Programming BasicArduino Programming Basic
Arduino Programming Basic
LITS IT Ltd,LASRC.SPACE,SAWDAGOR BD,FREELANCE BD,iREV,BD LAW ACADEMY,SMART AVI,HEA,HFSAC LTD.
 
arduino and its introduction deep dive ppt.pptx
arduino and its introduction deep dive ppt.pptxarduino and its introduction deep dive ppt.pptx
arduino and its introduction deep dive ppt.pptx
SruSru1
 
Sensors and Actuators in Arduino, Introduction
Sensors and Actuators in Arduino, IntroductionSensors and Actuators in Arduino, Introduction
Sensors and Actuators in Arduino, Introduction
BibekPokhrel13
 
Introduction of Arduino Uno
Introduction of Arduino UnoIntroduction of Arduino Uno
Introduction of Arduino Uno
Md. Nahidul Islam
 
How to use an Arduino
How to use an ArduinoHow to use an Arduino
How to use an Arduino
AntonAndreev13
 
Introduction to the Arduino
Introduction to the ArduinoIntroduction to the Arduino
Introduction to the Arduino
Wingston
 
Introduction to Arduino and Circuits
Introduction to Arduino and CircuitsIntroduction to Arduino and Circuits
Introduction to Arduino and Circuits
Jason Griffey
 
Arduino slides
Arduino slidesArduino slides
Arduino slides
sdcharle
 
Arduino Workshop Slides
Arduino Workshop SlidesArduino Workshop Slides
Arduino Workshop Slides
mkarlin14
 
Basics of open source embedded development board (
Basics of open source embedded development board (Basics of open source embedded development board (
Basics of open source embedded development board (
Dhruwank Vankawala
 
Basics of open source embedded development board (
Basics of open source embedded development board (Basics of open source embedded development board (
Basics of open source embedded development board (
Dhruwank Vankawala
 
teststststststLecture_3_2022_Arduino.pptx
teststststststLecture_3_2022_Arduino.pptxteststststststLecture_3_2022_Arduino.pptx
teststststststLecture_3_2022_Arduino.pptx
ethannguyen1618
 
Syed IoT - module 5
Syed  IoT - module 5Syed  IoT - module 5
Syed IoT - module 5
Syed Mustafa
 
Arduino
ArduinoArduino
Arduino
Jerin John
 
introductiontoarduino-111120102058-phpapp02.pdf
introductiontoarduino-111120102058-phpapp02.pdfintroductiontoarduino-111120102058-phpapp02.pdf
introductiontoarduino-111120102058-phpapp02.pdf
HebaEng
 
Chapter 5 Arduino Microcontroller Systems .pptx
Chapter 5 Arduino Microcontroller Systems .pptxChapter 5 Arduino Microcontroller Systems .pptx
Chapter 5 Arduino Microcontroller Systems .pptx
khgh7
 
arduinoworkshop-160204051621.pdf
arduinoworkshop-160204051621.pdfarduinoworkshop-160204051621.pdf
arduinoworkshop-160204051621.pdf
AbdErrezakChahoub
 
01 Intro to the Arduino and it's basics.ppt
01 Intro to the Arduino and it's basics.ppt01 Intro to the Arduino and it's basics.ppt
01 Intro to the Arduino and it's basics.ppt
pindi2197
 
Starting with Arduino
Starting with Arduino Starting with Arduino
Starting with Arduino
MajdyShamasneh
 
arduino and its introduction deep dive ppt.pptx
arduino and its introduction deep dive ppt.pptxarduino and its introduction deep dive ppt.pptx
arduino and its introduction deep dive ppt.pptx
SruSru1
 
Sensors and Actuators in Arduino, Introduction
Sensors and Actuators in Arduino, IntroductionSensors and Actuators in Arduino, Introduction
Sensors and Actuators in Arduino, Introduction
BibekPokhrel13
 
Introduction to the Arduino
Introduction to the ArduinoIntroduction to the Arduino
Introduction to the Arduino
Wingston
 
Introduction to Arduino and Circuits
Introduction to Arduino and CircuitsIntroduction to Arduino and Circuits
Introduction to Arduino and Circuits
Jason Griffey
 
Arduino slides
Arduino slidesArduino slides
Arduino slides
sdcharle
 
Arduino Workshop Slides
Arduino Workshop SlidesArduino Workshop Slides
Arduino Workshop Slides
mkarlin14
 
Basics of open source embedded development board (
Basics of open source embedded development board (Basics of open source embedded development board (
Basics of open source embedded development board (
Dhruwank Vankawala
 
Basics of open source embedded development board (
Basics of open source embedded development board (Basics of open source embedded development board (
Basics of open source embedded development board (
Dhruwank Vankawala
 
teststststststLecture_3_2022_Arduino.pptx
teststststststLecture_3_2022_Arduino.pptxteststststststLecture_3_2022_Arduino.pptx
teststststststLecture_3_2022_Arduino.pptx
ethannguyen1618
 
Syed IoT - module 5
Syed  IoT - module 5Syed  IoT - module 5
Syed IoT - module 5
Syed Mustafa
 
Ad

Recently uploaded (20)

Influence line diagram in a robust model
Influence line diagram in a robust modelInfluence line diagram in a robust model
Influence line diagram in a robust model
ParthaSengupta26
 
UNIT-5-PPT Computer Control Power of Power System
UNIT-5-PPT Computer Control Power of Power SystemUNIT-5-PPT Computer Control Power of Power System
UNIT-5-PPT Computer Control Power of Power System
Sridhar191373
 
Application Security and Secure Software Development Lifecycle
Application  Security and Secure Software Development LifecycleApplication  Security and Secure Software Development Lifecycle
Application Security and Secure Software Development Lifecycle
DrKavithaP1
 
Software_Engineering_in_6_Hours_lyst1728638742594.pdf
Software_Engineering_in_6_Hours_lyst1728638742594.pdfSoftware_Engineering_in_6_Hours_lyst1728638742594.pdf
Software_Engineering_in_6_Hours_lyst1728638742594.pdf
VanshMunjal7
 
Proposed EPA Municipal Waste Combustor Rule
Proposed EPA Municipal Waste Combustor RuleProposed EPA Municipal Waste Combustor Rule
Proposed EPA Municipal Waste Combustor Rule
AlvaroLinero2
 
world subdivision.pdf...................
world subdivision.pdf...................world subdivision.pdf...................
world subdivision.pdf...................
bmmederos12
 
하이플럭스 락피팅 카달로그 2025 (Lok Fitting Catalog 2025)
하이플럭스 락피팅 카달로그 2025 (Lok Fitting Catalog 2025)하이플럭스 락피팅 카달로그 2025 (Lok Fitting Catalog 2025)
하이플럭스 락피팅 카달로그 2025 (Lok Fitting Catalog 2025)
하이플럭스 / HIFLUX Co., Ltd.
 
Structural Health and Factors affecting.pptx
Structural Health and Factors affecting.pptxStructural Health and Factors affecting.pptx
Structural Health and Factors affecting.pptx
gunjalsachin
 
Software Developer Portfolio: Backend Architecture & Performance Optimization
Software Developer Portfolio: Backend Architecture & Performance OptimizationSoftware Developer Portfolio: Backend Architecture & Performance Optimization
Software Developer Portfolio: Backend Architecture & Performance Optimization
kiwoong (daniel) kim
 
Influence line diagram for truss in a robust
Influence line diagram for truss in a robustInfluence line diagram for truss in a robust
Influence line diagram for truss in a robust
ParthaSengupta26
 
Numerical Investigation of the Aerodynamic Characteristics for a Darrieus H-t...
Numerical Investigation of the Aerodynamic Characteristics for a Darrieus H-t...Numerical Investigation of the Aerodynamic Characteristics for a Darrieus H-t...
Numerical Investigation of the Aerodynamic Characteristics for a Darrieus H-t...
Mohamed905031
 
ISO 4548-9 Oil Filter Anti Drain Catalogue.pdf
ISO 4548-9 Oil Filter Anti Drain Catalogue.pdfISO 4548-9 Oil Filter Anti Drain Catalogue.pdf
ISO 4548-9 Oil Filter Anti Drain Catalogue.pdf
FILTRATION ENGINEERING & CUNSULTANT
 
MODULE 4 BUILDING PLANNING AND DESIGN SY BTECH HVAC SYSTEM IN BUILDING
MODULE 4 BUILDING PLANNING AND DESIGN SY BTECH HVAC SYSTEM IN BUILDINGMODULE 4 BUILDING PLANNING AND DESIGN SY BTECH HVAC SYSTEM IN BUILDING
MODULE 4 BUILDING PLANNING AND DESIGN SY BTECH HVAC SYSTEM IN BUILDING
Dr. BASWESHWAR JIRWANKAR
 
Electrical and Electronics Engineering: An International Journal (ELELIJ)
Electrical and Electronics Engineering: An International Journal (ELELIJ)Electrical and Electronics Engineering: An International Journal (ELELIJ)
Electrical and Electronics Engineering: An International Journal (ELELIJ)
elelijjournal653
 
Air Filter Flat Sheet Media-Catalouge-Final.pdf
Air Filter Flat Sheet Media-Catalouge-Final.pdfAir Filter Flat Sheet Media-Catalouge-Final.pdf
Air Filter Flat Sheet Media-Catalouge-Final.pdf
FILTRATION ENGINEERING & CUNSULTANT
 
All about the Snail Power Catalog Product 2025
All about the Snail Power Catalog  Product 2025All about the Snail Power Catalog  Product 2025
All about the Snail Power Catalog Product 2025
kstgroupvn
 
Highway Engineering - Pavement materials
Highway Engineering - Pavement materialsHighway Engineering - Pavement materials
Highway Engineering - Pavement materials
AmrutaBhosale9
 
[HIFLUX] Lok Fitting&Valve Catalog 2025 (Eng)
[HIFLUX] Lok Fitting&Valve Catalog 2025 (Eng)[HIFLUX] Lok Fitting&Valve Catalog 2025 (Eng)
[HIFLUX] Lok Fitting&Valve Catalog 2025 (Eng)
하이플럭스 / HIFLUX Co., Ltd.
 
Axial Capacity Estimation of FRP-strengthened Corroded Concrete Columns
Axial Capacity Estimation of FRP-strengthened Corroded Concrete ColumnsAxial Capacity Estimation of FRP-strengthened Corroded Concrete Columns
Axial Capacity Estimation of FRP-strengthened Corroded Concrete Columns
Journal of Soft Computing in Civil Engineering
 
Influence line diagram in a robust model
Influence line diagram in a robust modelInfluence line diagram in a robust model
Influence line diagram in a robust model
ParthaSengupta26
 
UNIT-5-PPT Computer Control Power of Power System
UNIT-5-PPT Computer Control Power of Power SystemUNIT-5-PPT Computer Control Power of Power System
UNIT-5-PPT Computer Control Power of Power System
Sridhar191373
 
Application Security and Secure Software Development Lifecycle
Application  Security and Secure Software Development LifecycleApplication  Security and Secure Software Development Lifecycle
Application Security and Secure Software Development Lifecycle
DrKavithaP1
 
Software_Engineering_in_6_Hours_lyst1728638742594.pdf
Software_Engineering_in_6_Hours_lyst1728638742594.pdfSoftware_Engineering_in_6_Hours_lyst1728638742594.pdf
Software_Engineering_in_6_Hours_lyst1728638742594.pdf
VanshMunjal7
 
Proposed EPA Municipal Waste Combustor Rule
Proposed EPA Municipal Waste Combustor RuleProposed EPA Municipal Waste Combustor Rule
Proposed EPA Municipal Waste Combustor Rule
AlvaroLinero2
 
world subdivision.pdf...................
world subdivision.pdf...................world subdivision.pdf...................
world subdivision.pdf...................
bmmederos12
 
하이플럭스 락피팅 카달로그 2025 (Lok Fitting Catalog 2025)
하이플럭스 락피팅 카달로그 2025 (Lok Fitting Catalog 2025)하이플럭스 락피팅 카달로그 2025 (Lok Fitting Catalog 2025)
하이플럭스 락피팅 카달로그 2025 (Lok Fitting Catalog 2025)
하이플럭스 / HIFLUX Co., Ltd.
 
Structural Health and Factors affecting.pptx
Structural Health and Factors affecting.pptxStructural Health and Factors affecting.pptx
Structural Health and Factors affecting.pptx
gunjalsachin
 
Software Developer Portfolio: Backend Architecture & Performance Optimization
Software Developer Portfolio: Backend Architecture & Performance OptimizationSoftware Developer Portfolio: Backend Architecture & Performance Optimization
Software Developer Portfolio: Backend Architecture & Performance Optimization
kiwoong (daniel) kim
 
Influence line diagram for truss in a robust
Influence line diagram for truss in a robustInfluence line diagram for truss in a robust
Influence line diagram for truss in a robust
ParthaSengupta26
 
Numerical Investigation of the Aerodynamic Characteristics for a Darrieus H-t...
Numerical Investigation of the Aerodynamic Characteristics for a Darrieus H-t...Numerical Investigation of the Aerodynamic Characteristics for a Darrieus H-t...
Numerical Investigation of the Aerodynamic Characteristics for a Darrieus H-t...
Mohamed905031
 
MODULE 4 BUILDING PLANNING AND DESIGN SY BTECH HVAC SYSTEM IN BUILDING
MODULE 4 BUILDING PLANNING AND DESIGN SY BTECH HVAC SYSTEM IN BUILDINGMODULE 4 BUILDING PLANNING AND DESIGN SY BTECH HVAC SYSTEM IN BUILDING
MODULE 4 BUILDING PLANNING AND DESIGN SY BTECH HVAC SYSTEM IN BUILDING
Dr. BASWESHWAR JIRWANKAR
 
Electrical and Electronics Engineering: An International Journal (ELELIJ)
Electrical and Electronics Engineering: An International Journal (ELELIJ)Electrical and Electronics Engineering: An International Journal (ELELIJ)
Electrical and Electronics Engineering: An International Journal (ELELIJ)
elelijjournal653
 
All about the Snail Power Catalog Product 2025
All about the Snail Power Catalog  Product 2025All about the Snail Power Catalog  Product 2025
All about the Snail Power Catalog Product 2025
kstgroupvn
 
Highway Engineering - Pavement materials
Highway Engineering - Pavement materialsHighway Engineering - Pavement materials
Highway Engineering - Pavement materials
AmrutaBhosale9
 
Ad

Arduino tutorial A to Z

  • 1. Introduction to Arduino Microcontroller Prepared by: Md. Asaduzzaman Dept of ICT, MBSTU Prepared by- Md Asaduzzaman , Dept of ICT,MBSTU 1
  • 2. Contents  What is Microcontroller?  What is Arduino?  Types of Arduino?  Installation process  Types Sensors? - Digital, Analog sensors.  Motor control  Coding structure and examples with C/C++ Library File? 1. Data types and operators. 2. What is “Function”? 3. Control statements [if, if… else, switch case.]. 4. Loop statements[while, for, do… while.]. 5. Common functions. Prepared by- Md Asaduzzaman , Dept of ICT,MBSTU 2
  • 3. What is a Microcontroller ? Prepared by- Md Asaduzzaman , Dept of ICT,MBSTU 3
  • 4. Microcontroller  It is a micro-computer. As any computer it has internal CPU, RAM,IOs interface.  Microcontroller = internally (CPU+RAM+IO interface) integrated device  It is used for control purposes, and for data analysis.  Must Need a Programmer.  Work as, both Master or Slave device.  Famous microcontroller manufacturers are MicroChip, Atmel,Atmega, Intel,IBM etc. Prepared by- Md Asaduzzaman , Dept of ICT,MBSTU 4
  • 5. Microcontroller Programmer  Hardware : PIC Programmer, Pocket AVR Programmer etc.  Software : (AVR,AVRISP,USBISP,USBASP) . Prepared by- Md Asaduzzaman , Dept of ICT,MBSTU 5 USB PIC Microcontroller Programmer
  • 6. What is the difference between Microcomputer and Microcontroller ? Prepared by- Md Asaduzzaman , Dept of ICT,MBSTU 6
  • 7. What is Arduino Microcontroller ??  It is Open Source (Hardware + Software) and single board microcontroller.  Work as, both Master or Slave device.  Arduino = internally CPU+RAM+IO interfaces + programmer (AVR,AVRISP,USBISP,USBASP) .  In 2005, a project was initiated to make a device for controlling student-built interactive design projects that was less expensive than other prototyping systems available at the time.  Founders Massimo Banzi and David Cuartielles named the project after Arduin of Ivrea and began producing boards in a small factory located in Ivrea. Prepared by- Md Asaduzzaman , Dept of ICT,MBSTU 7
  • 8. General Structure of Arduino ? Prepared by- Md Asaduzzaman , Dept of ICT,MBSTU 8
  • 9. Arduino Specification  Microcontroller ATmega328  Operating Voltage 5V and 3.3 V  Baud Rate : 9600, 14400, 19200, 28800, 38400, 57600, or 115200 bps.  Input Voltage (recommended) 7-12V  Input Voltage (limits) 6-20V  Digital I/O Pins 14 (of which 6 provide PWM output)  Analog Input Pins 6  DC Current per I/O Pin 40 mA  DC Current for 3.3V Pin50 mA  Flash Memory 32 KB (ATmega328) of which 0.5 KB used by Bootloader  SRAM 2 KB (ATmega328)  EEPROM 1 KB (ATmega328)  Clock Speed 16 MHz  Other Prototyping Platform:  Raspberry pie  Beagle board  Panda board  Cotton candy  Cubie Board  APC Rock  Hackberry  Gooseberry Prepared by- Md Asaduzzaman , Dept of ICT,MBSTU 9
  • 10. Types of Arduino ? Prepared by- Md Asaduzzaman , Dept of ICT,MBSTU 10
  • 11. Specification of different Types of Arduino -01 Prepared by- Md Asaduzzaman , Dept of ICT,MBSTU 11
  • 12. Specification of different Types of Arduino -02 Prepared by- Md Asaduzzaman , Dept of ICT,MBSTU 12
  • 13. Arduino Based Sensor Prepared by- Md Asaduzzaman , Dept of ICT,MBSTU 13
  • 14. Types of Sensor  Two types: 1. Digital Sensor 2. Analog Sensor Prepared by- Md Asaduzzaman , Dept of ICT,MBSTU 14
  • 15. Frequently Used Sensor  Humidity sensor (DHT22) - Digital Sensor  Temperature sensor (LM35) - Analog Sensor  Water detector sensor (Simple Water Trigger) - Digital Sensor  PIR SENSOR - Digital Sensor  ULTRASONIC SENSOR - Digital Sensor  Sound Sensor - Digital Sensor  GPS Prepared by- Md Asaduzzaman , Dept of ICT,MBSTU 15
  • 16. Humidity Sensor (DHT22) –Digital Sensor  Technical Details Power − 3-5V Max Current − 2.5mA Humidity − 0-100%, 2-5% accuracy Temperature − 40 to 80°C, ±0.5°C accuracy Prepared by- Md Asaduzzaman , Dept of ICT,MBSTU 16
  • 17. Temperature Sensor (LM35) Analog Sensor Technical Specifications:  Calibrated directly in Celsius (Centigrade)  Linear + 10-mV/°C scale factor.0.5°C ensured accuracy (at 25°C)  Rated for full −55°C to 150°C range  Suitable for remote applications Prepared by- Md Asaduzzaman , Dept of ICT,MBSTU 17
  • 18. Water Sensor (Digital Sensor) Technical Specification:  Water sensor has three terminals – S,Vout(+), and GND (-). Connect the sensor as follows −  Connect the +Vs to +5v on your Arduino board.  Connect S to digital pin number 8 on Arduino board.  Connect GND with GND on Arduino. Prepared by- Md Asaduzzaman , Dept of ICT,MBSTU 18
  • 19. PIR (Pyroelectric/Passive Infrared Radiation) Sensor (Digital Sensor) Technical Specification:  PIR sensor has three terminals : Vcc, OUT and GND. Connect the sensor as follows −  Connect the +Vcc to +5v on Arduino board.  Connect OUT to digital pin on Arduino board.  Connect GND with GND on Arduino. Prepared by- Md Asaduzzaman , Dept of ICT,MBSTU 19
  • 20. Ultrasonic Sensor (HC-SR04) - Digital Sensor  Technical Specifications  Power Supply − +5V DC  Quiescent Current − <2mA  Working Current − 15mA  Effectual Angle − <15°  Ranging Distance − 2cm – 400 cm/1″ – 13ft  Resolution − 0.3 cm  Measuring Angle − 30 degree  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.Prepared by- Md Asaduzzaman , Dept of ICT,MBSTU 20
  • 21. Sound Detection Sensor (Digital Sensor) Prepared by- Md Asaduzzaman , Dept of ICT,MBSTU 21
  • 22. Control the different type of motor with Arduino Prepared by- Md Asaduzzaman , Dept of ICT,MBSTU 22
  • 23. Types of Motor ??  There are three different type of motors −  DC motor  Servo motor  Stepper motor DC Motor Servo motor Stepper motor Prepared by- Md Asaduzzaman , Dept of ICT,MBSTU 23
  • 24. Necessary Things to done a Project with Motor  Motor Driver : To control the direction of the spin of DC motor, without interchanging the leads, you can use a circuit called an H-Bridge(Motor Driver). An H-bridge is an electronic circuit that can drive the motor in both directions.  Example : L298, L293 ,ESC etc. Prepared by- Md Asaduzzaman , Dept of ICT,MBSTU 24 L298 Motor Driver
  • 25. Arduino Installation  First you must have your Arduino board and a USB cable.  Download Arduino IDE and driver.  IDE Link: ARDUINO 1.8.5 : https://www.arduino.cc/en/Main/Software (go for windows installer) Download and Install it.  Driver Link: https://www.dropbox.com/s/a1d4837hbfylipb/windows-driver- installer.exe?dl=0 Download and Install it. Prepared by- Md Asaduzzaman , Dept of ICT,MBSTU 25
  • 26. Run on IDE Prepared by- Md Asaduzzaman , Dept of ICT,MBSTU 26
  • 27. Basic Structure of a Sketch  Open/Create a Sketch and Save it with .ino extension. Prepared by- Md Asaduzzaman , Dept of ICT,MBSTU 27
  • 28. Open an Example Sketch Prepared by- Md Asaduzzaman , Dept of ICT,MBSTU 28
  • 29. Select a Board Prepared by- Md Asaduzzaman , Dept of ICT,MBSTU 29
  • 30. Select a Communication port Prepared by- Md Asaduzzaman , Dept of ICT,MBSTU 30
  • 31. Upload a Sketch A - used to check compile error. B - Upload the program (Sketch). C - Create new Sketch. D - Open a Sketch. E - Save a Sketch. F – Serial monitor is Used to Visualize of transformation of serial data. Prepared by- Md Asaduzzaman , Dept of ICT,MBSTU 31
  • 32. Arduino Programming with C/C++ Library File Prepared by- Md Asaduzzaman , Dept of ICT,MBSTU 32
  • 33. Life Cycle of Arduino Sketch Prepared by- Md Asaduzzaman , Dept of ICT,MBSTU 33
  • 34. Input and Output Function  pinMode(Pin_no, Mode);  Mode= Input/Output on Analog or Digital pin  digitalRead(D_Pin_no);  digitalWrite(D_Pin_no, High/Low);  delay(time_ms);  other functions:  analogRead(A_Pin_no);  analogWrite(A_pin_no, PWM_input); //PWM. Prepared by- Md Asaduzzaman , Dept of ICT,MBSTU 34
  • 35. PWM (Pulse Width Modulation) Prepared by- Md Asaduzzaman , Dept of ICT,MBSTU 35
  • 36. Data Type : Like as C/C++ Prepared by- Md Asaduzzaman , Dept of ICT,MBSTU 36
  • 37. Operators : Like as C/C++  - Math operators: [+,-,*,/,%,^,++]  - Logic operators: [==, !=, &&, || ]  - Comparison operators: [==, >, <, !=, <=, >=]  Compound Operators: ++ (increment) -- (decrement) += (compound addition) -= (compound subtraction) *= (compound multiplication) /= (compound division)  - Other : ; = Semicolon, {} = curly braces, // = single line comment, /*Multi-line comments*/ Prepared by- Md Asaduzzaman , Dept of ICT,MBSTU 37
  • 38. Control Statement: Like as C/C++  If(condition) {…………}  If(condition) {………….} else {…………..}  If (condition) {…} else if (condition) {….} else {………}  switch (var) { case 1: //do something when var equals 1 break; case 2: //do something when var equals 2 break; default: // if nothing else matches, do the default // default is optional } Prepared by- Md Asaduzzaman , Dept of ICT,MBSTU 38
  • 39. Loop Statement: Like as C/C++  Do… while: do { Statements; break; } while(condition); // the statements are run at least once.  While: While(condition) {statements; break; }  for for (int i=0; i <= val; i++){ statements; break; } Prepared by- Md Asaduzzaman , Dept of ICT,MBSTU 39
  • 40. Basic Structure of a Simple Project: 01 Blinking LED (Send a Digital Serial Write command to a Slave (Sensors, LEDs, Motors etc.)) void setup() //the setup function runs once when you press reset or power the board. { pinMode(3, OUTPUT); // initialize digital pin 3 as an output. } void loop() // the loop function runs over and over again forever. { digitalWrite(3, HIGH); // turn the LED on (HIGH is the voltage level). delay(1000); // wait for a second. digitalWrite(3, LOW); // turn the LED off by making the voltage LOW. delay(1000); // wait for a second. } Prepared by- Md Asaduzzaman , Dept of ICT,MBSTU 40
  • 41. Circuit Diagram of Project: 01 Prepared by- Md Asaduzzaman , Dept of ICT,MBSTU 41
  • 42. Basic Structure of a Simple Project: 02 Digital Serial Data Reading (Receive a command from a Slave (Sensors, LEDs, Motors etc.)) int pushButton = 2; // digital pin 2 has a pushbutton attached to it. Give it a name: void setup() { Serial.begin(9600); // initialize serial communication at 9600 bits per second: pinMode(pushButton, INPUT); // make the pushbutton's pin an input: } void loop() { int buttonState = digitalRead(pushButton); // read the input pin: Serial.println(buttonState); // print out the state of the button: delay(1); // delay in between reads for stability } Prepared by- Md Asaduzzaman , Dept of ICT,MBSTU 42
  • 43. Basic Structure of a Simple Project: 03 Analog Serial Data Reading (Receive a command from a Slave ((Sensors, LEDs, Motors etc.)) void setup() { Serial.begin(9600); // initialize serial communication at 9600 bits per second: } void loop() { int sensorValue = analogRead(A0); // read the input on analog pin 0: float voltage = sensorValue*(5.0/1023.0); // Convert the analog reading(0-1023) to a voltage(0-5V): Serial.println(voltage); // print out the value you read: } Prepared by- Md Asaduzzaman , Dept of ICT,MBSTU 43
  • 44. Circuit diagram of Project- 03 Potentiometer Prepared by- Md Asaduzzaman , Dept of ICT,MBSTU 44
  • 45. Basic Structure of a Simple Project: 04 (Send a Analog Serial Write PWM command to a Slave (Sensors, LEDs, Motors etc.)) void setup() { Serial.begin(9600); // initialize serial communication at 9600 bits per second: } void loop() { int Value = random(0,1023); //set a analog serial data (which goes from 0 - 1023) to a voltage (0 - 5V): float voltage = Value * (5.0 / 1023.0); analogWrite(A1,voltage); // write the input on analog pin 1: Serial.println(voltage); // print out the value you write: } Prepared by- Md Asaduzzaman , Dept of ICT,MBSTU 45
  • 46. Can anyone tell us the Sketch (code) of merging the idea of Project -01,02,03 and Project - 04 ?? Prepared by- Md Asaduzzaman , Dept of ICT,MBSTU 46
  • 47. Merge circuit Diagram of Project -03 and Project -04 Prepared by- Md Asaduzzaman , Dept of ICT,MBSTU 47
  • 48. Test Our Skills : (PWM) Anyone Please explain Where PWM is used? int led = 3,brightness = 0,fadeAmount = 5; void setup() { pinMode(led, OUTPUT); } void loop() { analogWrite(led, brightness); brightness = brightness + fadeAmount; if (brightness == 0 || brightness == 255) { fadeAmount = -fadeAmount ; } delay(30); } Prepared by- Md Asaduzzaman , Dept of ICT,MBSTU 48
  • 49. Basic Project -05 Control the Spin of Motor const int pwm = 10 ; const int in_1 = 9 ; const int in_2 = 8 ; void setup() { pinMode(pwm,OUTPUT) ; pinMode(in_1,OUTPUT) ; pinMode(in_2,OUTPUT) ; } void loop() { digitalWrite(in_1,HIGH) ; digitalWrite(in_2,LOW) ; analogWrite(pwm,255) ; //Clockwise for 3 secs delay(3000) ; digitalWrite(in_1,LOW) ; digitalWrite(in_2,HIGH) ; delay(3000) ; //Anti-Clockwise for 3 secs } Prepared by- Md Asaduzzaman , Dept of ICT,MBSTU 49
  • 50. Basic Project -05 Control the Spin of Motor Circuit diagram Prepared by- Md Asaduzzaman , Dept of ICT,MBSTU 50
  • 51. Project -06 : A Simple Home Security System  Basic Idea : To build an human detection System for your Home using Arduino on 220v AC.  Instruments:  Arduino  PIR Sensor.  Relay Module (The relay board works on 220V AC .So keep necessary safety measurements.).  LED and Buzzer.  Motor.  Jumper Wire and Breadboard.  L298 Motor Driver. Prepared by- Md Asaduzzaman , Dept of ICT,MBSTU 51
  • 52. Project -06 :Smart home Security Circuit Diagram Prepared by- Md Asaduzzaman , Dept of ICT,MBSTU 52
  • 53. Project-06: Sketch of Home Security System int LED = 3; int PIR = 2; int Buzzer = 7; void setup() { pinMode(LED, OUTPUT); pinMode(Buzzer, OUTPUT); pinMode(PIR, INPUT); } Prepared by- Md Asaduzzaman , Dept of ICT,MBSTU 53 void loop() { int value = digitalRead(PIR); if (value == HIGH){ digitalWrite(LED, HIGH); digitalWrite(Buzzer, HIGH); } else { digitalWrite(LED, LOW); digitalWrite(Buzzer, LOW); } }
  • 54. Project -07:Clap controlled Smart home Circuit Diagram Prepared by- Md Asaduzzaman , Dept of ICT,MBSTU 54
  • 55. Video Tutorial of Building the Clap Control Prepared by- Md Asaduzzaman , Dept of ICT,MBSTU 55
  • 56. Project References  http://www.instructables.com/technology/arduino/ for project idea.  https://playground.arduino.cc/Projects/Ideas .  https://codebender.cc/home for project code Must need Firefox/chrome.  https://github.com for project code.  https://youtube.com for tutorial.  https://learn.sparkfun.com/tutorials for tutorial.  https://www.allaboutcircuits.com/projects/category/arduino/ for tutorial.  https://diyhacking.com/diy-projects/arduino-projects/ for project idea.  http://mertarduinotutorial.blogspot.com for tutorial.  Arduino for Dummies by- John Nussey.  Arduino Programming by- Simon Monk. Prepared by- Md Asaduzzaman , Dept of ICT,MBSTU 56
  • 57. Any Question ?? Prepared by- Md Asaduzzaman , Dept of ICT,MBSTU 57
  • 58. Thank You Prepared by- Md Asaduzzaman , Dept of ICT,MBSTU 58