Project tutorial

Soft potentiometer tutorial © GPL3+

This tutorial will show you how to use the Soft Potentiomenter produced by plug and wear.  

  • 757 views
  • 0 comments
  • 0 respects

Components and supplies

Ard lilusb
Arduino LilyPad USB
×1
Soft potentiometer kit
×1

About this project

1. Introduction

The soft potentiometer is made of fabric and works like a normal potentiometer. It has a metal ring that you can slide and change the value that you Arduino reads.

2. Connect the potentiometer to the power supply

Connect the two ends of the potentiometer to the power supply. One to ground and the other to 5 V.

3. Connect the potentiometer to the board

Connect the moving part of the potentiometer to the analog input A5 of Arduino Lilypad.

4. How to read the potentiometer value

The Arduino can read the potentiometer value using the analogRead function. It will read a value between 0 and 1024 that depends on the position of the metal ring along the potentiometer. The value of the potentiometer will change the frequency of the LED blinking.

Here is the code:

int sensorPin = A5;    // select the input pin for the potentiometer
int ledPin = 13;      // select the pin for the LED
int sensorValue = 0;  // variable to store the value coming from the sensor
void setup() {
  // declare the ledPin as an OUTPUT:
  pinMode(ledPin, OUTPUT);
}
void loop() {
  // read the value from the sensor:
  sensorValue = analogRead(sensorPin);
  // turn the ledPin on
  digitalWrite(ledPin, HIGH);
  // stop the program for <sensorValue> milliseconds:
  delay(sensorValue);
  // turn the ledPin off:
  digitalWrite(ledPin, LOW);
  // stop the program for for <sensorValue> milliseconds:
  delay(sensorValue);
}

Code

Code snippet #1Arduino
int sensorPin = A5;    // select the input pin for the potentiometer
int ledPin = 13;      // select the pin for the LED
int sensorValue = 0;  // variable to store the value coming from the sensor

void setup() {
  // declare the ledPin as an OUTPUT:
  pinMode(ledPin, OUTPUT);
}

void loop() {
  // read the value from the sensor:
  sensorValue = analogRead(sensorPin);
  // turn the ledPin on
  digitalWrite(ledPin, HIGH);
  // stop the program for <sensorValue> milliseconds:
  delay(sensorValue);
  // turn the ledPin off:
  digitalWrite(ledPin, LOW);
  // stop the program for for <sensorValue> milliseconds:
  delay(sensorValue);
}

Comments

Similar projects you might like

Magic Lamp

by Nekhil ravi

  • 1,047 views
  • 3 comments
  • 12 respects

PuzzleBox

Project tutorial by Arduino

  • 296 views
  • 0 comments
  • 1 respect

Arduino MKR GSM 1400 and DTMF

by Arduino_Genuino

  • 4,066 views
  • 0 comments
  • 9 respects

Love You Pillow

Project tutorial by Arduino

  • 2,592 views
  • 0 comments
  • 5 respects

Arduino Yun Controller

Project showcase by TATCO Inc

  • 182 views
  • 0 comments
  • 3 respects
Add projectSign up / Login