INPUT THE INPUTS ON THE ARDUINO READ VOLTAGE. ALL INPUTS NEED TO - - PowerPoint PPT Presentation

input the inputs on the arduino read voltage all inputs
SMART_READER_LITE
LIVE PREVIEW

INPUT THE INPUTS ON THE ARDUINO READ VOLTAGE. ALL INPUTS NEED TO - - PowerPoint PPT Presentation

INPUT THE INPUTS ON THE ARDUINO READ VOLTAGE. ALL INPUTS NEED TO BE THOUGHT OF IN TERMS OF VOLTAGE DIFFERENTIALS. THE ANALOG INPUTS CONVERT VOLTAGE LEVELS TO A NUMERICAL VALUE. PULL-UP (OR DOWN) RESISTOR Often it is useful to steer an


slide-1
SLIDE 1

INPUT

slide-2
SLIDE 2

THE INPUTS ON THE ARDUINO READ VOLTAGE. ALL INPUTS NEED TO BE THOUGHT OF IN TERMS OF VOLTAGE DIFFERENTIALS. THE ANALOG INPUTS CONVERT VOLTAGE LEVELS TO A NUMERICAL VALUE.

slide-3
SLIDE 3

PULL-UP (OR DOWN) RESISTOR

slide-4
SLIDE 4

Often it is useful to steer an input pin to a known state if no input is present. This can be done by adding a pullup resistor (to +5V), or a pulldown resistor (resistor to ground) on the input. A 10K resistor is a good value for a pullup or pulldown resistor.

slide-5
SLIDE 5

PUSH BUTTON WITH PULL-DOWN RESISTOR

When the button isn’t pressed, the voltage going to pin 7 is “pulled down” to 0 because it is connected, via the resistor, to ground. When the button is pressed, the resistance going to ground is higher than that going to the input pin so the full voltage is sent to the pin.

slide-6
SLIDE 6

CONTROL AN LED WITH A BUTTON

slide-7
SLIDE 7

USING THE INTERNAL PULL-UP RESISTOR

When the button isn’t pressed, the voltage going to pin is “pulled up” to HIGH. When the button is pressed, the connection to ground is completed so the pin is LOW.

slide-8
SLIDE 8

CONTROL AN LED WITH A BUTTON

slide-9
SLIDE 9

TOGGLE AN LED WITH A BUTTON

Only change the state of the LED when there is a change from LOW to HIGH on the button. The “old_val” variable holds the state of the button the last time through loop.

slide-10
SLIDE 10

TOGGLE AN LED WITH A BUTTON + DEBOUNCING

Only change the state of the LED when there is a change from LOW to HIGH on the button. The “old_val” variable holds the state of the button the last time through loop.

slide-11
SLIDE 11

ANYTHING CAN BECOME A SWITCH

slide-12
SLIDE 12

ANALOG INPUT

slide-13
SLIDE 13

POTENTIOMETER

slide-14
SLIDE 14

POTENTIOMETER WITH BLINKING LED

1 1 5 5 10 10 15 15 20 20 25 25 30 30 A A B B C C D D E E F F G G H H I I J J 13 12 11 10 9 8 7 6 5 4 3 2 L 5V A0 ANALOG IN AREF 1 GND TX RX RESET 3V3 A1 A2 A3 A4 A5 VIN GND GND DIGITAL (PWM= ) Arduino TM IOREF ICSP ICSP2 ON POWER 1 TX0 RX0 RESET
slide-15
SLIDE 15

READ ANALOG VALUES AND BLINK LED

analogRead() gives values in a range from 0-1024.

slide-16
SLIDE 16

POTENTIOMETER WITH PWM LED

1 1 5 5 10 10 15 15 20 20 25 25 30 30 A A B B C C D D E E F F G G H H I I J J 13 12 11 10 9 8 7 6 5 4 3 2 L 5V A0 ANALOG IN AREF 1 GND TX RX RESET 3V3 A1 A2 A3 A4 A5 VIN GND GND DIGITAL (PWM= ) Arduino TM IOREF ICSP ICSP2 ON POWER 1 TX0 RX0 RESET
slide-17
SLIDE 17

READ ANALOG VALUES AND FADE LED

analogRead() gives values in a range from 0-1024. analogWrite() can only write values from 0-255. To account for this we divide the value received from analogRead() by 4.

slide-18
SLIDE 18

VOLTAGE DIVIDER

slide-19
SLIDE 19

VOLTAGE DIVIDER

The resistor closest to the input voltage (Vin) is called R1, and the resistor closest to ground R2. The voltage drop across R2 is called Vout, that’s the divided voltage our circuit exists to make.

slide-20
SLIDE 20

THE EQUATION

slide-21
SLIDE 21

IF R2 AND R1 ARE EQUAL THEN THE OUTPUT VOLTAGE IS HALF THAT OF THE INPUT. IF R2 IS MUCH LARGER THAN R1 (AT LEAST AN ORDER OF MAGNITUDE) THEN THE OUTPUT VOLTAGE WILL BE VERY CLOSE TO THE INPUT. IF R2 IS MUCH SMALLER THAN R1 THEN OUTPUT VOLTAGE WILL BE TINY COMPARED TO THE INPUT.

slide-22
SLIDE 22

PHOTOCELL WITH VOLTAGE DIVIDER

slide-23
SLIDE 23

PHOTOCELL WITH VOLTAGE DIVIDER

Light Level R2 (Sensor) R1 (Fixed) Ratio R2/(R1+R2) Vout Light 1kΩ 5.6kΩ 0.15 0.76 V Dim 7kΩ 5.6kΩ 0.56 2.78 V Dark 10kΩ 5.6kΩ 0.67 3.21 V

slide-24
SLIDE 24

PHOTOCELL WITH VOLTAGE DIVIDER

Light Level R2 (Sensor) R1 (Fixed) Ratio R2/(R1+R2) Vout Light 1kΩ 5.6kΩ 0.15 0.76 V Dim 7kΩ 5.6kΩ 0.56 2.78 V Dark 10kΩ 5.6kΩ 0.67 3.21 V

What the input pin gets

slide-25
SLIDE 25

VOLTAGE DIVIDER

You can “tune” the output of the sensor by changing the value of R1.

slide-26
SLIDE 26

READ ANALOG INPUT VALUES

slide-27
SLIDE 27

READ ANALOG VALUES AND CONTROL LED

analogRead() gives values in a range from 0-1024. analogWrite() can only write values from 0-255. To account for this we divide the value received from analogRead() by 4.

slide-28
SLIDE 28

PRESSURE SENSOR WITH VOLTAGE DIVIDER

slide-29
SLIDE 29

PRESSURE SENSOR WITH VOLTAGE DIVIDER

slide-30
SLIDE 30

READ ANALOG INPUT VALUES

slide-31
SLIDE 31

READ ANALOG VALUES AND CONTROL LED

analogRead() gives values in a range from 0-1024. analogWrite() can only write values from 0-255. To account for this we divide the value received from analogRead() by 4.