LED TO LNR
Arduino uno
Presenters:
Bilal Afzal Awan
(General Member Technical)
INTRODUCTION
General Computer Micro Controller
• Enormous • Small size
• High processing power • Low processing power
• Multiple IOs • Limited IOs
• General purpose • Specifically designed
• Large storage • Small Storage
• Higher cost • Cheaper
• Operating system • Firmware
2
Why
controllers?
Real time examples
Proximity sensor
Car security lock system
3
MICROCONTROLLER
What is Arduino?
4
IMPORTANCE OF DATASHEET
Lets move to the datasheet !
Pune Makers ( http://www.meetup.com/Pune-Makers/ ) 5
ARDUINO UNO
What does it have?
14 Digital In/Out pins (6 can be used as PWM)
6 Analog Inputs
A USB Connection
A Power Jack
Reset Button
On-board LED
SCL/SDA pins (Serial Clock/ Serial Data pins)
The Arduino Uno is a microcontroller board based on the ATmega328 .
The ATmega328 has Flash memory of 32 KB (with 0.5 KB used for the
bootloader). It also has 2 KB of SRAM and 1 KB of EEPROM
6
USB
(to Computer)
ARDUINO UNO
PWR IN
RESET
POWER
5V / 3.3V /
GND
Digital I\O
PWM(3, 5, 6, 9, 10,
11)
Analog
INPUTS
7
3 TYPES OF I/O
PINS
• DIGITAL
• PWM
• ANALOG
DIGITAL PINS
Pune Makers ( http://www.meetup.com/Pune-Makers/ ) 9
PWM
On Arduino Uno, which has an 8-bit PWM
resolution, values range from 0 to 255. This
means that the analogWrite() function,
commonly used for PWM on Arduino, takes
values from 0 (completely off) to 255 (fully
on).
Here's a breakdown of the PWM values and
their corresponding duty cycles:
•0: 0% duty cycle (completely off)
•64: 25% duty cycle
•128: 50% duty cycle (midpoint)
•192: 75% duty cycle
•255: 100% duty cycle (completely on)
REMEMBER ELECTRIC CIRCUITS AND EDC! 10
ANALOG PINS
What are analog pins?????
What are analog pins????
What are analog pins???
What are analog pins??
What are analog pins?
Team technical- 11
INPUT VS OUTPUT
Sensors vs Actuators
12
ANALOG VS DIGITAL
Microcontrollers are digital devices – ON or OFF. Also called – discrete.
Analog signals are anything that can be a full range of values.
5V 5V
0V 0V
13
LETS SEE WHAT HAVE WE
LEARNED
WHAT HAVE WE LEARNED ?
• IF I WANT TO RUN OR STOP A MOTOR WHICH PIN
SHOULD BE USED?
IF I WANT TO CONTROL THE SPEED WHAT SHOULD I DO ?
Pune Makers ( http://www.meetup.com/Pune-Makers/ ) 15
LET’S START
CODING
HARDWARE GUY VS SOFTWARE
GUY
A FEW BASIC CONCEPTS
pinMode()
digitalWrite()
delay()
analogWrite()
If/Else
digitalRead()
analogRead()
Serial Communication
Pune Makers ( http://www.meetup.com/Pune-Makers/ ) 18
ARDUINO IDE
Once you have downloaded and
installed/extracted the folder,
you can directly run Arduino.exe,
which will take you to its IDE.
The IDE will look like the shown
screenshot.
Pune Makers ( http://www.meetup.com/Pune-Makers/ ) 19
3 EASY STEPS
Whats up???????? 20
Pune Makers ( http://www.meetup.com/Pune-Makers/ ) 21
Pune Makers ( http://www.meetup.com/Pune-Makers/ ) 22
Pune Makers ( http://www.meetup.com/Pune-Makers/ ) 23
FUNCTIONS
Believe me these are useful! 24
PIN ADDRESSING
The pins of the arduino can either
be directly used or for better
useability, these pin are also
stored in some variable.
This helps when there is need to
change one pin, but it wouldn’t be
good to search for that pin
number in the whole program.
25
PINMODE
Takes two input arguments as the
name of pin and the working.
Defines the pin as either the Input
or the output.
Should always be defined in void
setup() for every pin that is to be
used later
26
DIGITAL WRITE
This is a built-in function of
Arduino that sets the pin to either
HIGH or LOW.
Here high represents 5v and low
represents the ground.
Any pin set to HIGH shall remain
high unless it is digitally written
back to LOW.
27
DELAY
This function generates the delay
in milliseconds
This function induces the time
delay between the next command
by putting the sequence on sleep.
This function can sometime
disturb the flow
28
DIGITAL READ
This function reads the value of
the voltage available at the pin.
The pin will be read as HIGH if the
voltage available is above 3 volts
and vice versa
29
SERIAL COMMUNICATION
This process connect the
computer with the Arduino
It helps in sending and receiving
of the data.
The data received is usually really
helpful in the debugging
purposes.
The data is communicated via the
Serial Monitor
30
CONDITIONAL STATEMENTS
These statements play a vital role
in defining the flow of the
program.
On the basis of these statements
it is checked whether the specific
block of code is to be considered
If-statement when set false the
following else-statement shall be
executed
31
ANALOG WRITE
This uses the digital PWM pins to
deliver the analog output.
The value given between 0 to 255
to this function will deliver the
voltage to this pin corresponding
value given value.
Use of non-PWM pin will result in
invalid responses
32
TASK # 1
You are being asked to use the
already gained knowledge to
make a circuit as given in figure.
This circuit should be
programmed in the following
order
LED-1 turns ON for 0.5 sec
It then Turns OFF for 0.5 sec
LED-2 turns ON for 1 sec.
It turns OFF for 1 sec.
Pune Makers ( http://www.meetup.com/Pune-Makers/ ) 33
33
TASK # 2
You are required to make the
following circuit and program it in
such a way that whenever there
is something near the IR sensor
the LED turns ON
Pune Makers ( http://www.meetup.com/Pune-Makers/ ) 34
34
TASK # 3
You are required to make the
following circuit and program it in
such a way that you should be
able to control the speed of a dc
geared motor.
35
WHAT’S NEXT !?
36
THANK YOU
ANY
QUESTIONS?
You can have your lunch during class! 38