I'm trying to get the potentiometer seen at the top left of the photo to work, essentially as a dimmer. I've managed to upload the Arduino sketch, but it isn't working. Any help would be greatly appreciated! NB: I have little-to-no electronics experience so my understanding of jargon is limited.


 SENSOR_LIGHTS: Potentiometer >> LED (Single Channel Script)

 This example dims light levels using an LED on pin 11
 and a potentiometer on A0. 

 Created by Ryan Achten | SOMA | somavisions.com

 This example code is in the public domain.

int potentLevel;
int ledLevel;


int led = 11;           // the pin that the LED is attached to
int inputPin = A0;      // the pin that the potentiometer is attached to


const int numReadings = 1;  //change this to alter the number of values to be averaged
int potentMin = 280; 
int potentMax = 700;        //maximum output from potentiometer
int loopDelay = 100;       //delay time between loops. Too low may cause overclocking  
//                            while too high may cause delayed sensor response


int potentAve = 0;
int readings[numReadings];
int index = 0;
int total = 0;

// the setup routine runs once when you press reset:
void setup()  { 

  //*************************POTENT >> LED SETUP CODE*************************


  pinMode(led, OUTPUT);

  //***************************SMOOTH SETUP CODE*****************************
  // initialise all the readings to 0: 
  for (int thisReading = 0; thisReading < numReadings; thisReading++)
    readings[thisReading] = 0;  


//****************************SMOOTH LOOP CODE****************************

void loop()  { 

  total= total - readings[index];         
  readings[index] = analogRead(inputPin); 
  total= total + readings[index];       
  index = index + 1;  

  if (index >= numReadings)              
    index = 0;                           

  potentAve = total / numReadings;         
  Serial.print("Average Potentiometer Readings: ");

  //*************************POTENT >> LED LOOP CODE*************************

  ledLevel = map(potentAve, potentMin, potentMax, 0, 255);
  Serial.print("LED Level: ");
  Serial.println(ledLevel, DEC);
  analogWrite(led, ledLevel);



Electronics Schematic

Photo of electronics

  • 1
    According to your schematic, it seems that both the red and the blue wire of the potentiometer are connected to GND? If so, this will never work. What does your Serial output tell for "Average Potentiometer Readings"?
    – mic
    Sep 15, 2015 at 9:12
  • Yes, this was one problem! I'd put it in GND instead of 5V by accident. Thanks for that!
    – Velocir
    Sep 16, 2015 at 0:50

1 Answer 1


Assuming the brown board in your drawing is stripboard, I have to as the question:

What is this?

enter image description here

If those five wires in that column are all ground, that link is basically short circuiting your MOSFET via the green wire next to it, thus rendering your whole circuit pointless. The LEDs will just be on full brightness permanently since the current just flows from the input power, through the LED strip, through the red/white wire, through that little white link wire, then through the green/white and/or the brown/white wires to ground.

  • It was a wire I was using to replace a resistor, because some classmates found that getting rid of the resistor meant that the LED strip would go all the way off, which they don't otherwise. I've given up on that and put a resistor in, and now it works. Thanks for your help!
    – Velocir
    Sep 16, 2015 at 0:53

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.