Wednesday 9/14/2016 – Sensing: Potentiometers

Readings

  • Physical Computing by Igoe & O’Sullivan (2004)
    Ch 6. pgs 87-136 (for this week and next week)
    Soldering [pp.41-42]

Lecture Slides

Available here.

Before the Lab

You should have already successfully built the 3 LED (RGB) circuit and gotten them to fade with various color combinations. Congratulations!

In Lab Exercise

Objective

In this lab, we explore analog input. Specifically, we’ll be looking at variable resistance devices known as potentiometers or “pots” for short. These are also known as “knobs” that you might be familiar with turning in other user interfaces, such as the volume knob on a radio. In exploring analog input, we will use Arduino to read pot values and control the LEDs based on those pot values. We’ll also be moving away from the more elementary circuit diagrams to the more advanced circuit schematic diagrams.

Activities

Part 1: Soldering

First we need to prepare the pot so that can easily connect it to our circuit. We do this by soldering wires to it.

1) Take 1 red, 1 black, 1 yellow wires, and 1 pot (One pot is in your kit).

2) Strip off about ¼” of the insulation from each of these wires.
3) Solder wires to the pot.*
Match the colors of the wires as in the image below.
Soldering often requires more than 2 hands. That’s why we have “helping hands”. Use them like in the image below to secure your pot and your wire.
To solder, you place the soldering iron on the wire/terminal and heat the joint, then apply the solder (keep the tip on the joint), remove the solder, then remove the iron in that order.
Let it cool before moving it around (it’ll take just a few seconds).
*We have lead free solder but if you are soldering anywhere else, you should know that solder often contains lead and so many pregnant women refrain from soldering or make sure they are using lead free solder.
Part 2: Controlling one LED from the one Pot

1) Extend your 3 LED circuit so that it includes a pot. Follow the circuit diagrammed below

You an see that the red wire goes to power, the black wire goes to ground, and the yellow wire goes to Pin A0 on the Arduino.

2) Use the potentiometer to control the blinking rate of the LEDs. On the Arduino website, there is some sample code which takes the pot value as input and uses it to control the blinking speed of an LED. You can also find the Arduino sketch here. https://www.arduino.cc/en/Tutorial/AnalogInput . You can ignore the stuff about photoresistors and just look at the stuff involving potentiometers and LEDs. MAKE SURE YOU DOUBLE CHECK THE PIN NUMBERS. Your should make sure that your pot is plugged in to pin A0 (A-Zero) so that it matches the pin in the arduino sketch. This is determined by this line in the arduino sketch:

in sensorPin = A0; // select the input pin for the potentiometer
Also, the arduino sketch linked to above controls an LED plugged into pin 13, but your LED is probably plugged in to a different pin. If your LEDs are plugged into different pins, change the line
int ledPin = 13; // select the pin for the LED
in the Arduino sketch to match the pin you are using. This sketch only makes one LED blink; see if you can modify the code to make all your LEDs blink. You can try adding other LEDs by adding lines of code like so:
int redledPin = 9;
int blueledPin = 10;
int greenledPin = 11;
3) At this tutorial, there is some sample code which takes the pot value as input and uses it to control the brightness level of an LED. http://owenmundy.com/blog/2010/05/fading-an-led-with-pwm-and-a-potentiometer/ . Again, make sure that you are using the right pins for your potentiometer and LED. This is good practice for when you find arduino sketches online and you have to modify it for what you want.

Part 3: Multiple Pots controlling multiple LEDs

1) There are two options for this part.

a) Option 1: Needs 2 pots. Use one pot to control the brightness and the other pot to control the blinking.

b) Use three pots, each pot controls the brightness of one LED. So one pot controls the red LED, one pot controls the blue LED, and one pot controls the green LED. (You may need to get extra pots from us and solder on the wires).

Homework: Due September 20 at 11:59PM

Use multiple pots to control your LEDs
Option 1: One pot controls brightness, another pot controls blinking
Option 2: 3 Pots for 3 LEDs (each pot controls brightness of RGB Hue / colors)
(Note that this Homework is the same thing as Part 3. Your homework is just to finish Part 3.)
Extra points:
Come up with an interesting mapping between the rotational position pot and LED output.