Week 2 - Making Things Move
Agenda
Artist(s) of the Day

Daniel Rozin
Analog Output
Commonly called PWM (Pulse Width Modulation).

https://www.arduino.cc/en/Tutorial/BuiltInExamples/Fade
- NOTE: this is a very similar circuit and wiring as Digital Output above.
- the difference is that here we are using
analogWrite() (reference)
- and a different pin (one of the PWM capable pins)
- Demo:
- Show the “duty cycle” on the oscilloscope.
- Show how a different analog output corresponds to (1) a waveform and (2) a different measured voltage.
- TODO:
Making Things Move
Another use of Pulse Width Modulation is driving the position of a servo motor.
Servo Sweep
- Install the ESP32Servo library:
- Tools -> Manage Libraries:
- Search for ESP32Servo. Click Install:

- Under Examples -> ESP32Servo, select the Sweep example:

- Make sure that your servo is connected to the pins used in the example code. Or change the pins in the code to match your setup.

- Wire up the servo:
- BLACK/BROWN -> Ground
- RED/YELLOW -> +5V
- ORANGE -> your
servoPin.
- Compile and run the example.
What is PWM?
Timing Diagram

Simplified Wiring Diagram

https://www.arduino.cc/en/Tutorial/LibraryExamples/Sweep
Talk Through
- How to read a schematic
- Pulse Width Modulation
Servo Knob
We are going to use the potentiometer knob as an input device. You can think of a knob as a kind of simple “sensor” to drive the servo motion.
- Under Examples -> ESP32Servo, select the Knob example:


- Reading the schematic.
- Use the knob to control the servo.
Homework
References