control angle via button pushes one button increases angle. other decreases angle. both light led

12
5V 0 22 24 26 28 30 32 34 36 38 40 42 44 46 48 50 52 GND 5V 0 23 29 31 33 35 37 39 41 43 45 47 49 51 53 PW M /DIGITAL CO M M UNICATIO N PO W ER ANALO G IN DIG ITAL A0 A1 A2 A3 A4 A5 A6 A7 A8 A9 A10 A11 A12 A13 A14 A15 14 15 16 17 18 19 20 21 TX3 RX3 TX2 RX2 TX1 RX1 SCA SCL 77 7 76 6 75 5 74 4 74 3 72 2 71 TX0 70 RX0 RST 3V3 5V0 GND GND VIN 27 GND 25 SERVO 85 ARE 84 GND 83 13 82 12 81 11 80 10 79 9 78 8 GROUND POW ER SIG N AL INCREASE DECREASE BUTTON PUSHED ntrol Angle via Button Pus One button increases angle. Other decreases angle. Both light LED.

Upload: primrose-harvey

Post on 30-Dec-2015

216 views

Category:

Documents


3 download

TRANSCRIPT

Page 1: Control Angle via Button Pushes One button increases angle. Other decreases angle. Both light LED

5V0

22242628303234363840424446485052GND

5V0

23

29313335373941434547495153

PWM/DIGITALCOMMUNICATION

POWER ANALOG IN

DIG

ITA

L

A0

A1

A2

A3

A4

A5

A6

A7

A8

A9

A10

A11

A12

A13

A14

A15

14 15 16 17 18 19 20 21

TX

3

RX3

TX

2

RX2

TX

1

RX1

SC

A

SC

L

777

766

755

744

743

722

71T

X0

70R

X0

RS

T

3V3

5V0

GN

D

GN

D

VIN

27

GND

25

SERVO

85A

RE

84G

ND

8313

8212

8111

8010

799

788

GROUND POWER

SIGNAL

INCREASE

DECREASE

BUTTONPUSHED

Control Angle via Button PushesOne button increases angle.Other decreasesangle.Both light LED.

Page 2: Control Angle via Button Pushes One button increases angle. Other decreases angle. Both light LED

Servo Control Using Analog Signal

5V0

22242628303234363840424446485052GND

5V0

23

29313335373941434547495153

PWM/DIGITALCOMMUNICATION

POWER ANALOG IN

DIG

ITA

L

A0

A1

A2

A3

A4

A5

A6

A7

A8

A9

A10

A11

A12

A13

A14

A15

14 15 16 17 18 19 20 21

TX

3

RX3

TX

2

RX2

TX

1

RX1

SC

A

SC

L

777

766

755

744

743

722

71T

X0

70R

X0

RS

T

3V3

5V0

GN

D

GN

D

VIN

27

GND

25

SERVO

85A

RE

84G

ND

8313

8212

8111

8010

799

788

GROUND POWER

SIGNAL

POTENTIOMETER(variable resistor)

WIPER

Obtain “analog” inputusing analogRead().

Page 3: Control Angle via Button Pushes One button increases angle. Other decreases angle. Both light LED

Voltage, V• Voltage tells us how hard a positive charge is

pushed between two different points.• Something, such as a battery, is needed to create

a voltage.

Current, I• Current tells us the amount of charge flowing through

something (similar to gallons per minute).• Current must have a path through which to flow.

Resistor: RI = V / R

V = 5, R = 5, I = ?

Page 4: Control Angle via Button Pushes One button increases angle. Other decreases angle. Both light LED

5 V

R

?V

5 V

R

?V

What Is the Measured Voltage?

0V 5V

Page 5: Control Angle via Button Pushes One button increases angle. Other decreases angle. Both light LED

What Is the Measured Voltage?

5V

5 V

R

?V

5 V

R

?V

5V

Page 6: Control Angle via Button Pushes One button increases angle. Other decreases angle. Both light LED

What Is the Measured Voltage?5 V

R

?V

5 V

R

?V

0V 0V

Page 7: Control Angle via Button Pushes One button increases angle. Other decreases angle. Both light LED

What Is the Measured Voltage?5 V

R/2?V

R/2

5 V

R/2

R/2

?V

0V 5V

Page 8: Control Angle via Button Pushes One button increases angle. Other decreases angle. Both light LED

What Is the Measured Voltage?

5 V

R/2

R/2

?V

2.5V

Page 9: Control Angle via Button Pushes One button increases angle. Other decreases angle. Both light LED

What Is the Measure Voltage?

5 V

R/5

R/5?V

R/5

R/5

R/5

?V

?V

?V

?V

?V

0V1V2V3V4V5V

Page 10: Control Angle via Button Pushes One button increases angle. Other decreases angle. Both light LED

Potentiometer5 V

R?V

WIPER

• Voltage at wiper depends onposition along the resistor.

• Voltage varies between ground(0V) and the supplied voltage(5V in this case).

• Voltage various continuously(analog “signal”).

Page 11: Control Angle via Button Pushes One button increases angle. Other decreases angle. Both light LED

Conversion of Analog to Digital• Obtain “analog” input using analogRead().

• analogRead() returns a value between 0 (if pin at ground) and 1023 (if pin at 3.3 V).

• Argument of analogRead() is the pin to read(only pins labeled ANALOG IN can be used).

• Servo position varies between 0 and 180.Therefore, must divide analogRead() whatreturns by 5.68333 (1023 / 5.68333 = 180).

Page 12: Control Angle via Button Pushes One button increases angle. Other decreases angle. Both light LED

5V0

22242628303234363840424446485052GND

5V0

23

29313335373941434547495153

PWM/DIGITALCOMMUNICATION

POWER ANALOG IN

DIG

ITA

L

A0

A1

A2

A3

A4

A5

A6

A7

A8

A9

A10

A11

A12

A13

A14

A15

14 15 16 17 18 19 20 21

TX

3

RX3

TX

2

RX2

TX

1

RX1

SC

A

SC

L

777

766

755

744

743

722

71T

X0

70R

X0

RS

T

3V3

5V0

GN

D

GN

D

VIN

27

GND

25

SERVO

85A

RE

84G

ND

8313

8212

8111

8010

799

788

GROUND POWER

SIGNAL

INCREASE

DECREASE

BUTTONPUSHED

Control Angle via Button PushesOne button increases angle.Other decreasesangle.Both light LED.