SparkFun Inventor's Kit for MicroView

Pages
Contributors: Joel_E_B
Favorited Favorite 5

Experiment 11: Soft Potentiometer

Introduction

In this circuit you’ll work with a soft potentiometer. Back in Experiment 2, you used a regular potentiometer to vary the resistance of a circuit. With the soft pot, you can do all the same things you would with a regular potentiometer. However, this time the interface changes, showing you how you can accomplish the same tasks with different forms of the same technology or with different technologies altogether.

Parts Needed

You will need the following parts:

  • 1x Soft Potentiometer
  • 2x 330Ω resistor (Orange Orange Brown Gold)
  • 2x Jumper Wires

Breadboard Setup

Hook up your circuit as pictured below. The soft pot is polarized, so pay attention to its orientation. The side with the adhesive back is the bottom, and the side with the touch strips is the top (as pictured below).

Circuit11

MicroView Arduino Code

language:c
#include <MicroView.h>              // include MicroView library

MicroViewWidget  *widget;           // declare widget pointer

int sensorValue;                    // declare variable to store sensor value
int sensorPin=A0;                   // declare sensor pin as A0 of Arduino  

void setup() {
  uView.begin();                    // start MicroView  
  uView.clear(PAGE);                // clear page
  widget = new MicroViewSlider(0,0,0,1024, WIDGETSTYLE1);   // declare widget as slider
  pinMode(sensorPin, INPUT);                // set sensor pin as INPUT
}

void loop () {
  sensorValue=analogRead(sensorPin);        // read and store sensor value
  widget->setValue(sensorValue);            // set sensor value to widget
  uView.display();                          // display widget
  delay(20);                                // delay 20 ms
}

What You Should See

As you move a blunt long object (like your finger) up and down the soft potentiometer, the MicroView Slider Widget should change it’s value accordingly. If it isn’t working, make sure you have assembled the circuit correctly and verified and uploaded the code to your MicroView, or see the troubleshooting tips below.

Troubleshooting

Bizarre Results

The most likely cause of this is if you’re pressing the potentiometer in more than one position. This is normal and can actually be used to create some neat results.

Still No Success?

A broken circuit is no fun, send us an e-mail and we will get back to you as soon as we can: TechSupport@sparkfun.com