SIK_circuit02_potentiometer by SparkFun SIK Examples

Measure the position of a potentiometer and use it to control the blink rate of an LED. Turn the knob to make it blink faster or slower!

Hardware connections:

Potentiometer:

Potentiometers have three pins. When we're using it as a voltage divider, we connect the outside pins to power and ground. The middle pin will be the signal (a voltage which varies from 0 Volts to 5 Volts depending on the position of the knob).

  • Connect the middle pin to ANALOG IN pin 0 on the Arduino.
  • Connect one of the outside pins to 5V.
  • Connect the other outside pin to GND.

(TIP: if once your program is running, the knob feels "backwards", you can swap the 5V and GND pins to reverse the direction.)

LED:

Most Arduinos already have an LED and resistor connected to pin 13, so you may not need any additional circuitry.

But if you'd like to connect a second LED to pin 13, or use a different pin, follow these steps:

  • Connect the positive side of your LED (longer leg) to Arduino digital pin 13 (or another digital pin, but don't forget to change the code to match).
  • Connect the negative side of your LED (shorter leg) to a 330 Ohm resistor (orange-orange-brown).
  • Connect the other side of the resistor to ground.

Wiring Diagram

enter link description here

Embed This Sketch

Use the following HTML code to embed the sketch code above in your blog or website.

<iframe style="height: 510px; width: 100%; margin: 10px 0 10px;" allowTransparency="true" src="https://codebender.cc/embed/sketch:77047" frameborder="0"></iframe>

Embed The Serial Monitor

You can also embed the Serial Monitor section! Just use this HTML code.

<iframe style="height: 510px; width: 100%; margin: 10px 0 10px;" allowTransparency="true" src="https://codebender.cc/embed/serialmonitor" frameborder="0"></iframe>