Project tutorial

Soft potentiometer tutorial © GPL3+

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

  • 1,340 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

Arduino Bluetooth Basic Tutorial

by Mayoogh Girish

  • 454,928 views
  • 42 comments
  • 239 respects

Home Automation Using Raspberry Pi 2 And Windows 10 IoT

Project tutorial by Anurag S. Vasanwala

  • 285,510 views
  • 95 comments
  • 671 respects

Security Access Using RFID Reader

by Aritro Mukherjee

  • 229,298 views
  • 38 comments
  • 236 respects

OpenCat

Project in progress by Team Petoi

  • 195,878 views
  • 154 comments
  • 1,360 respects
Add projectSign up / Login