ucsd-et4a

Week 2 - Making Things Move

Agenda

Artist(s) of the Day

image

Daniel Rozin

Analog Input and Output

Analog Output

Commonly called PWM (Pulse Width Modulation).

Image

https://www.arduino.cc/en/Tutorial/BuiltInExamples/Fade

Analog Input

Image

https://www.arduino.cc/en/Tutorial/BuiltInExamples/AnalogInput

Analog Read Serial

https://docs.arduino.cc/built-in-examples/basics/AnalogReadSerial

Photoresistor Part 1

https://www.arduino.cc/en/Tutorial/BuiltInExamples/AnalogInput

Making Things Move

Another use of Pulse Width Modulation is driving the position of a servo motor.

Servo Sweep

image

Image

https://www.arduino.cc/en/Tutorial/LibraryExamples/Sweep

Servo Knob

A knob is a kind of simple “sensor” to drive the servo motion.

Image

Image

Photoresistor Part 2

With the photoresistor setup and arduino code from part 1 above:

  1. Use map() to scale those analog values to 0 -> 180 degrees (the full range of the servo)
  2. Interact with the photoresistor and see the motor move.
  3. Extension: Instead of directly mapping sensor values to servo position, use the sensor values to trigger specific motions. For instance, have if statements that move it to different positions depending on how much light it sees.

Homework

References