Go Down

Topic: Membrane pot issue (Read 1 time) previous topic - next topic


I'm trying to get a line of 3 LEDs to start flickering according to where a person's finger is on a membrane pot. So as you slide your finger up the pot, one by one the LEDs start flickering. This all works fine at the moment.

When there is no pressure on the membrane pot, the LEDs should stay lit on full brightness.

The thing is, even if I'm not touching the membrane pot at all, the LEDs flicker when they should be staying bright - like there's information coming from the sensor. There seems to be some kind of interference interrupting the program.

I've tried various things to fix it:

  • changing boards (Duemilanove to Diecimila) - didn't change anything

  • changing breadboards/components - didn't change anything

  • changing to an external power supply rather than USB to computer - didn't change anything

  • this is the strangest thing - I disconnected the wire connecting the sensor to the analog in pin so that the sensor wasn't telling the LEDs anything - the flickering continued like I hadn't changed anything.

I'm not even sure if this is a problem with the sensor or not. I swapped it for an LDR and the issue stopped, but as I listed above, it doesn't seem to be something to do with the sensor...

I thought it might have to do something with the code I was using, but I've never had this problem before when I've used the same methods with other sensors. I'll post it here anyway.

Code: [Select]

int potPin = 0;    // select the input pin for the potentiometer
int ledPin11 = 11;   // select the pin for the LED
int ledPin10 = 10;
int ledPin9 = 9;
int sensorValue = 0;       // variable to store the value coming from the sensor

void setup() {
  pinMode(potPin, INPUT);
  pinMode(ledPin11, OUTPUT);  // declare the ledPin as an OUTPUT
  pinMode(ledPin10, OUTPUT);  // declare the ledPin as an OUTPUT
  pinMode(ledPin9, OUTPUT);  // declare the ledPin as an OUTPUT

void loop() {

  sensorValue = 0;
  analogWrite(ledPin9, 255);
  analogWrite(ledPin10, 255); 
  analogWrite(ledPin11, 255); 
  sensorValue = analogRead(potPin);    // read the value from the sensor
  sensorValue = int(map(sensorValue,0,1024,0,255));

  if(sensorValue <100){
    int ranNum = random(0,255);
    analogWrite(ledPin9, ranNum); 
  if(sensorValue <50){
    int ranNum = random(0,255);
    analogWrite(ledPin10, ranNum);
  if(sensorValue <10){
    int ranNum = random(0,255);
    analogWrite(ledPin11, ranNum);

Any ideas? I'd like to get on with this project and this is really annoying me.


like there's information coming from the sensor.

Yes there is. It is called pickup, and is caused by there being no connection to the analogue input. This happens when there is no contact pressure.
To stop it happening you need a 10K resistor from the analogue input to ground. This is called a pull down resistor. It will also affect the values you read from the pot but hey that's how it is.

Go Up