servo control using analog signal obtain “analog” input using analogread()
TRANSCRIPT
![Page 1: Servo Control Using Analog Signal Obtain “analog” input using analogRead()](https://reader035.vdocument.in/reader035/viewer/2022071806/56649d8a5503460f94a710c9/html5/thumbnails/1.jpg)
Servo Control Using Analog Signal
5V0
22242628303234363840424446485052GND
5V0
23
29313335373941434547495153
PWM/DIGITALCOMMUNICATION
POWER ANALOG IN
DIGITAL
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
777
766
755
744
743
722
71TX0
70RX0
RST
3V3
5V0
GND
GND
VIN
27
GND
25
SERVO
85ARE
84GND
8313
8212
8111
8010
799
788
GROUND POWER
SIGNAL
POTENTIOMETER(variable resistor)
WIPER
Obtain “analog” inputusing analogRead().
![Page 2: Servo Control Using Analog Signal Obtain “analog” input using analogRead()](https://reader035.vdocument.in/reader035/viewer/2022071806/56649d8a5503460f94a710c9/html5/thumbnails/2.jpg)
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).
![Page 3: Servo Control Using Analog Signal Obtain “analog” input using analogRead()](https://reader035.vdocument.in/reader035/viewer/2022071806/56649d8a5503460f94a710c9/html5/thumbnails/3.jpg)
Pulse Width Modulation (PWM)
1Period 1Period1Period
90%DutyCycle 90%DutyCycle90%DutyCycle
Time
Voltage
1Period 1Period1Period
50%DutyCycle 50%DutyCycle50%DutyCycle
Time
![Page 4: Servo Control Using Analog Signal Obtain “analog” input using analogRead()](https://reader035.vdocument.in/reader035/viewer/2022071806/56649d8a5503460f94a710c9/html5/thumbnails/4.jpg)
1Period 1Period1Period
20%DutyCycle 20%DutyCycle20%DutyCycle
Time
Pulse Width Modulation (PWM)
1Period 1Period1PeriodTime
Voltage
DutyCycle=?100%
![Page 5: Servo Control Using Analog Signal Obtain “analog” input using analogRead()](https://reader035.vdocument.in/reader035/viewer/2022071806/56649d8a5503460f94a710c9/html5/thumbnails/5.jpg)
Pulse Width Modulation (PWM)
1Period 1Period1PeriodTime
Voltage
DutyCycle=?0%
• On the chipKIT there are 490 periods per second.• Use analogWrite(pin, value) to control
the duty cycle on a pin.• The value must be between 0 and 255.• The pin must be one of the underlined pins.
![Page 6: Servo Control Using Analog Signal Obtain “analog” input using analogRead()](https://reader035.vdocument.in/reader035/viewer/2022071806/56649d8a5503460f94a710c9/html5/thumbnails/6.jpg)
Pulse Width Modulation (PWM)• If you take the average value over one period,
you can think of the voltage as being between0 V (0% duty cycle) and 3.3 V (100% duty cycle).
• There are 256 different voltage levels.
• Can demonstrate this with an LED attached topin 9 and the example sketch Fading.
![Page 7: Servo Control Using Analog Signal Obtain “analog” input using analogRead()](https://reader035.vdocument.in/reader035/viewer/2022071806/56649d8a5503460f94a710c9/html5/thumbnails/7.jpg)
Pulse Width Modulation (PWM)
5V0
22242628303234363840424446485052GND
5V0
23
29313335373941434547495153
PWM/DIGITALCOMMUNICATION
POWER ANALOG IN
DIGITAL
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
777
766
755
744
743
722
71TX0
70RX0
RST
3V3
5V0
GND
GND
VIN
27
GND
2585
ARE
84GND
8313
8212
8111
8010
799
788
Upload example sketch Fading for this circuit.
![Page 8: Servo Control Using Analog Signal Obtain “analog” input using analogRead()](https://reader035.vdocument.in/reader035/viewer/2022071806/56649d8a5503460f94a710c9/html5/thumbnails/8.jpg)
5V0
22242628303234363840424446485052GND
5V0
23
29313335373941434547495153
PWM/DIGITALCOMMUNICATION
POWER ANALOG IN
DIGITAL
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
777
766
755
744
743
722
71TX0
70RX0
RST
3V3
5V0
GND
GND
VIN
27
GND
25
85ARE
84GND
8313
8212
8111
8010
799
788
POTENTIOMETER
WIPER
Pulse Width Modulation (PWM)
Write sketch led_with_potentiometer for this circuit.
![Page 9: Servo Control Using Analog Signal Obtain “analog” input using analogRead()](https://reader035.vdocument.in/reader035/viewer/2022071806/56649d8a5503460f94a710c9/html5/thumbnails/9.jpg)
Pulse Width Modulation (PWM)
5V0
22242628303234363840424446485052GND
5V0
23
29313335373941434547495153
PWM/DIGITALCOMMUNICATION
POWER ANALOG IN
DIGITAL
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
777
766
755
744
743
722
71TX0
70RX0
RST
3V3
5V0
GND
GND
VIN
27
GND
25
85ARE
84GND
8313
8212
8111
8010
799
788
INCREASE
DECREASE
Write sketch led_with_inc_and_dec for this circuit.