Misbehaving pot after moving to PCB design.

Hey Guys,

I have a circuit using an arduino that controls 8 leds and a CD4066, its for an fx box that has 8 programs. The LEDs are just to display which program is selected and are controlled directly by the arduino
When building the test circuit on the breadboard all was working fine. although I do seem to have misplaced the sketch and so had to write it again.

Only led 1 and 8 leds will light (basically, either end of the pot)
I'm getting a good 4.99V across the the pot,
I've checked and double checked the pin connections and continuity tested the led's to the arduino pins and all good there.
I've tried several pots, but these are all brand new 10k lin pots, checking the resistance on a multimeter checks out and the resistance changes smoothly when measuring and moving.

Using the serial monitor, I am reading from around 0-40 something, then, a huge deadzone for half the distance of the pot then for the last quarter of a turn reads from something like 1000-1023.

I'm fairly sure nothing is wrong with the code, I'm worrying that its something wrong i did on the PCB,

any ideas?

int fxselect;

void setup()
{  

// FX Program Select
pinMode (4, OUTPUT); // Program 1
pinMode (5, OUTPUT); // Program 2
pinMode (6, OUTPUT); // Program 3
pinMode (7, OUTPUT); // Program 4
pinMode (8, OUTPUT); // Program 5
pinMode (9, OUTPUT); // Prpgram 6
pinMode (10, OUTPUT); // Program 7
pinMode (11, OUTPUT); // Program 8

//Set Pin A2 as INPUT
pinMode (A2, INPUT);

// CD4066 CONTROL S0 S1 S2
pinMode (15, OUTPUT);
pinMode (16, OUTPUT);
pinMode (17, OUTPUT);

//Serial.begin(9600);
}


void loop()
{  
//int sensorValue = analogRead(A2);
fxselect = (analogRead(A2));
//Serial.println(sensorValue);

   if  (fxselect <128)
  { 
    digitalWrite(4, HIGH);
    digitalWrite(5, LOW);
    digitalWrite(6, LOW);
    digitalWrite(7, LOW);
    digitalWrite(8, LOW);
    digitalWrite(9, LOW);
    digitalWrite(10, LOW);
    digitalWrite(11, LOW);
    
    digitalWrite(15, LOW);
    digitalWrite(16, LOW);
    digitalWrite(17, LOW);
    
  }
  else 
    if  (fxselect >= 129 && fxselect < 256)
  { 
    digitalWrite(4, LOW);
    digitalWrite(5, HIGH);
    digitalWrite(6, LOW);
    digitalWrite(7, LOW);
    digitalWrite(8, LOW);
    digitalWrite(9, LOW);
    digitalWrite(10, LOW);
    digitalWrite(11, LOW);
    
    digitalWrite(15, LOW);
    digitalWrite(16, LOW);
    digitalWrite(17, HIGH);
    
  }
   else 
    if  (fxselect >= 257 && fxselect < 384)
  { 
    digitalWrite(4, LOW);
    digitalWrite(5, LOW);
    digitalWrite(6, HIGH);
    digitalWrite(7, LOW);
    digitalWrite(8, LOW);
    digitalWrite(9, LOW);
    digitalWrite(10, LOW);
    digitalWrite(11, LOW);
    
    digitalWrite(15, LOW);
    digitalWrite(16, HIGH);
    digitalWrite(17, LOW);
    
  }
  else 
    if  (fxselect >= 385 && fxselect < 512)
  { 
    digitalWrite(4, LOW);
    digitalWrite(5, LOW);
    digitalWrite(6, LOW);
    digitalWrite(7, HIGH);
    digitalWrite(8, LOW);
    digitalWrite(9, LOW);
    digitalWrite(10, LOW);
    digitalWrite(11, LOW);
    
    digitalWrite(15, LOW);
    digitalWrite(16, HIGH);
    digitalWrite(17, HIGH);
    
  }
  
  else 
    if  (fxselect >= 513 && fxselect < 640)
  { 
    digitalWrite(4, LOW);
    digitalWrite(5, LOW);
    digitalWrite(6, LOW);
    digitalWrite(7, LOW);
    digitalWrite(8, HIGH);
    digitalWrite(9, LOW);
    digitalWrite(10, LOW);
    digitalWrite(11, LOW);
    
    digitalWrite(15, HIGH);
    digitalWrite(16, LOW);
    digitalWrite(17, LOW);
    
  }
  
    else 
    if  (fxselect >= 641 && fxselect < 768)
  { 
    digitalWrite(4, LOW);
    digitalWrite(5, LOW);
    digitalWrite(6, LOW);
    digitalWrite(7, LOW);
    digitalWrite(8, LOW);
    digitalWrite(9, HIGH);
    digitalWrite(10, LOW);
    digitalWrite(11, LOW);
    
    digitalWrite(15, HIGH);
    digitalWrite(16, LOW);
    digitalWrite(17, HIGH);
    
  }
    else 
    if  (fxselect >= 769 && fxselect < 896)
  { 
    digitalWrite(4, LOW);
    digitalWrite(5, LOW);
    digitalWrite(6, LOW);
    digitalWrite(7, LOW);
    digitalWrite(8, LOW);
    digitalWrite(9, LOW);
    digitalWrite(10, HIGH);
    digitalWrite(11, LOW);
    
    digitalWrite(15, HIGH);
    digitalWrite(16, HIGH);
    digitalWrite(17, LOW);
    
  }
    else 
    if  (fxselect >= 897 && fxselect < 1024)
  { 
    digitalWrite(4, LOW);
    digitalWrite(5, LOW);
    digitalWrite(6, LOW);
    digitalWrite(7, LOW);
    digitalWrite(8, LOW);
    digitalWrite(9, LOW);
    digitalWrite(10, LOW);
    digitalWrite(11, HIGH);
    
    digitalWrite(15, HIGH);
    digitalWrite(16, HIGH);
    digitalWrite(17, HIGH);
    
  }
 
}

fx_handler.ino (3.43 KB)

Got a schematic & layout?

Where are the series resistors for each LED?
Do you have a pcb board layout?

I didnt have resistors on the breadboard when I made it up. and it worked fine, and still does. :frowning:

    if  (fxselect >= 129 && fxselect < 256)
 
    if  (fxselect >= 257 && fxselect < 384)
 
    if  (fxselect >= 385 && fxselect < 512)
  
    if  (fxselect >= 513 && fxselect < 640)
 
    if  (fxselect >= 641 && fxselect < 768)
 
    if  (fxselect >= 769 && fxselect < 896)
 
    if  (fxselect >= 897 && fxselect < 1024)

You have a few analogRead values that are not in any of the tests:
256, 384, 512, 640, 768,896
Doubt that is the problem; <= should be used tho.

Try taking the multiple else's out also.

Just uploaded an 'LED Chaser' sketch to the board and all the leds are chasing. on their own.
the pot is now controlling the speed of the lighchase effect, and as before only the two ends of the pot really has any effect.

I didnt have resistors on the breadboard when I made it up. and it worked fine, and still does.

Have fun with that... maybe next month you can come back and ask us "Why did my arduino pin stop working" or "Why did my LED go from lighting green to yellow? (or stop working?)" Maybe then you will start to understand why we asked about resistors.