Issues using PWM with leds

Hello, I am trying to use an Uno to manipulate leds for a prototype of a multi sectional bar light that uses leds as well. The problem I am running into is the PWM seems to be too slow and you can noticeably see the lights franticly flickering. Also, to dim these leds, I am using POTs to control the duty cycle of the PWM and when any of the 3 POTs are turn to zero resistance, all the lights flicker much more franticly, but I do not understand why because all of them are connected to separate circuits. I do have stunt resistors attached as well. I would appreciate any help!

BrowPrototype.ino (1.5 KB)

I cannot see your code as I do not have the IDE on my device and downloading and converting to a format that i can see is a pain in the ask. Please read the how to use this forum-please read stickies to see how to post code so that everyone can see it.

i agree fungus... but I have some puters read code with a text editor... still not ideal.

I will help on this one

Dear OP - please include a schematic and a detailed description of what you're trying to do.

#define MARKERIN  2
#define SPOTIN    A0
#define FLOODIN   A1
#define SCENEIN   A2
#define SPOT      3
#define FLOOD     5
#define SCENE     6
#define MARKER1    9
#define MARKER2    10
#define MARKER3    11

int spotPot = 0;
int floodPot = 0;
int scenePot = 0;
int timer = 0;
bool marker = false;
bool markerButt = false;

void setup() {

  Serial.begin(9600);
  delay(1000);

  pinMode(MARKERIN, INPUT); 
  pinMode(SPOTIN, INPUT); 
  pinMode(FLOODIN, INPUT); 
  pinMode(SCENEIN, INPUT); 
  pinMode(SPOT, OUTPUT); 
  pinMode(FLOOD, OUTPUT); 
  pinMode(SCENE, OUTPUT); 
  pinMode(MARKER1, OUTPUT); 
  pinMode(MARKER2, OUTPUT);
  pinMode(MARKER3, OUTPUT); 
  Serial.println("hello world");
  timer = millis();
  delay(2000);

}

void loop() {

  spotPot = analogRead(SPOTIN);
  floodPot = analogRead(FLOODIN);
  scenePot = analogRead(SCENEIN);
  Serial.println(spotPot);
  Serial.println(floodPot);
  Serial.println(scenePot);
  Serial.println();

  analogWrite(SPOT, spotPot);
  analogWrite(FLOOD, floodPot);
  analogWrite(SCENE, scenePot);

  if(digitalRead(MARKERIN)){
    markerButt = !markerButt;
    Serial.println("button pushed");
  }

  if((millis() - timer) > 2000 && markerButt){
    if(marker == false){
      digitalWrite(MARKER1, HIGH);
      digitalWrite(MARKER2, LOW);
      digitalWrite(MARKER3, HIGH);
      marker = !marker;
    }
    if(marker == true){
      digitalWrite(MARKER1, LOW);
      digitalWrite(MARKER2, HIGH);
      digitalWrite(MARKER3, LOW);
      marker = !marker;
    }
    timer = millis();
  }

}
{
    if(marker == false){
      digitalWrite(MARKER1, HIGH);
      digitalWrite(MARKER2, LOW);
      digitalWrite(MARKER3, HIGH);
      marker = !marker;
    }
    if(marker == true){
      digitalWrite(MARKER1, LOW);
      digitalWrite(MARKER2, HIGH);
      digitalWrite(MARKER3, LOW);
      marker = !marker;

look through this and please explain your logic... and follow the logical progression of this...

The problem with downloading code to a PC with the IDE is that you must create a folder on your PC to hold the .ino file and then you have to delete the folder afterwards. Properly posted code can easily be copied to the IDE or other editor and does not end up cluttering your PC.

analogWrite() takes a number 0~255.

analogRead() gives a number 0~1023

You need to scale the value you read from the pot accordingly.

When reading 0v, there will still be a bit of jitter in the ADC readings, so you get readings of 0, 1, 2, sometimes 3 when reading from a pot with turned all the way down. The simplest way to do this scaling would be to do:

 analogWrite(SPOT, spotPot>>2);
  analogWrite(FLOOD, floodPot>>2);
  analogWrite(SCENE, scenePot>>2);

Sometimes when switching between analog pins, the value is thrown off a little by the voltage on the pin previously read. To work around this, for each read, take a "dummy" reading of the same pin:

 analogRead(SPOTIN);
  spotPot = analogRead(SPOTIN);
  analogRead(FLOODIN);
  floodPot = analogRead(FLOODIN);
  analogRead(SCENEIN);
  scenePot = analogRead(SCENEIN);

mine just goes to download and open with a text editor on download on this puter... it does not have arduino IDE on it... you could dump it into online editor also... but we have forum tools to make it easier for everyone... PLEASE post correctly to help us help you.

A 0.1uF cap from the analog input to ground will help to stabilize the readings from the pot (low pass filter).