Analog pins vs PWM Pins

Ok so I’m working on a costume. Sleeping beauty and in the cartoon the dress switches from Pink to blue (the fairies fight over it). I’ve got Lilypad and a Adafruit FX Borad. So that before the dress switches color it goes with sounds from the movie of the fairies saying “Oh no not pink! Make it blue” Then when the magic wand sounds it changes colors. So I hooked up a test light an loved it! But then I tested the analog pins and colors aren’t the same. On the PWM pins it seams to match my code. You can see all 3 lights in the RGB lights light up to make pink… With the analog pins only the red lights up… I can’t figure out. Do I change the code for analog?

Here is PWM pins 9, 10, 11:

Same light hooked up to Analog pins A0,A1,A2:

I know its hard to tell but but the first one is pink and the second one is red…???

I know these don’t have the sound effects but thats cause i didn’t have speakers hooked up.
Here is the orginal test:

Any insight how to fix this color issue?

I attached the Code file, it wont let me past and copy, says it is too may characters…

Sleeping_Beauty_lights_and_sound.ino (8.36 KB)

A0, A1 A2 are analogue input pins.
If you use them as outputs, they're digital outputs.

int redPin1 = 3;
int greenPin1 = 5;
int bluePin1 = 6;
int redPin2 = 9;
int greenPin2 = 10;
int bluePin2 = 11;
int redPin3 = A0;
int greenPin3 = A1;
int bluePin3 = A2;
int redPin4 = A3;
int greenPin4 = A4;
int bluePin4 = A5;
int fx1 = 2;
int fx2 = 4;
int fx3 = 1;
int fx4 = 7;
int fx5 = 12;


void setup()
{
    pinMode(redPin1, OUTPUT);
    pinMode(greenPin1, OUTPUT);
    pinMode(bluePin1, OUTPUT);
    pinMode(redPin2, OUTPUT);
    pinMode(greenPin2, OUTPUT);
    pinMode(bluePin2, OUTPUT);
    pinMode(redPin3, OUTPUT);
    pinMode(greenPin3, OUTPUT);
    pinMode(bluePin3, OUTPUT);
    pinMode(redPin4, OUTPUT);
    pinMode(greenPin4, OUTPUT);
    pinMode(bluePin4, OUTPUT);
    pinMode(fx1, OUTPUT);
    pinMode(fx2, OUTPUT);
    pinMode(fx3, OUTPUT);
    pinMode(fx4, OUTPUT);
    pinMode(fx5, OUTPUT);
    
}

void loop()
{
digitalWrite(fx1, HIGH);
digitalWrite(fx2, HIGH);
digitalWrite(fx3, HIGH);
digitalWrite(fx4, HIGH);
digitalWrite(fx5, HIGH);

delay(1000);

digitalWrite(fx5,LOW);

delay(150);

digitalWrite(fx5,HIGH);
delay(300);

analogWrite(redPin1, 255);
analogWrite(greenPin1, 255);// White RGB Light light 1 left Side
analogWrite(bluePin1, 255);

analogWrite(redPin2, 255);
analogWrite(greenPin2, 255);// White RGB Light light 2 Left Side
analogWrite(bluePin2, 255);

analogWrite(redPin3, 255);
analogWrite(greenPin3, 255);// White RGB Light light 3 Right Side
analogWrite(bluePin3, 255);

analogWrite(redPin4, 255);
analogWrite(greenPin4, 255);// White RGB Light light 4 Right Side
analogWrite(bluePin4, 255);
   
   delay(250);
   
analogWrite(redPin1, 200);
analogWrite(greenPin1, 20);// Pink RGB Light light 1 left Side
analogWrite(bluePin1, 100);

analogWrite(redPin2, 200);
analogWrite(greenPin2, 20);// Pink RGB Light light 2 Left Side
analogWrite(bluePin2, 100);

analogWrite(redPin3, 200);
analogWrite(greenPin3, 20);// Pink RGB Light light 3 Right Side
analogWrite(bluePin3, 100);

analogWrite(redPin4, 200);
analogWrite(greenPin4, 20);// Pink RGB Light light 4 Right Side
analogWrite(bluePin4, 100);   
   
  delay(8000);
  
digitalWrite(fx1, LOW);

delay(150);

digitalWrite(fx1,HIGH);

delay(3700);

analogWrite(redPin1, 255);
analogWrite(greenPin1, 255);// White RGB Light light 1 left Side
analogWrite(bluePin1, 255);

analogWrite(redPin2, 255);
analogWrite(greenPin2, 255);// White RGB Light light 2 Left Side
analogWrite(bluePin2, 255);

analogWrite(redPin3, 255);
analogWrite(greenPin3, 255);// White RGB Light light 3 Right Side
analogWrite(bluePin3, 255);

analogWrite(redPin4, 255);
analogWrite(greenPin4, 255);// White RGB Light light 4 Right Side
analogWrite(bluePin4, 255);
   
   delay(250);

analogWrite(redPin1, 10);
analogWrite(greenPin1, 10);// Blue RGB Light light 1 left Side
analogWrite(bluePin1, 255);

analogWrite(redPin2, 10);
analogWrite(greenPin2, 10);// Blue RGB Light light 2 Left Side
analogWrite(bluePin2, 255);

analogWrite(redPin3, 10);
analogWrite(greenPin3, 10);// Blue RGB Light light 3 Right Side
analogWrite(bluePin3, 255);

analogWrite(redPin4, 10);
analogWrite(greenPin4, 10);// Blue RGB Light light 4 Right Side
analogWrite(bluePin4, 255);     
    
  delay(9000);
  
digitalWrite(fx2, LOW);

  delay(150);
    
digitalWrite(fx2, HIGH);

  delay(2450);

analogWrite(redPin1, 255);
analogWrite(greenPin1, 255);// White RGB Light light 1 left Side
analogWrite(bluePin1, 255);

analogWrite(redPin2, 255);
analogWrite(greenPin2, 255);// White RGB Light light 2 Left Side
analogWrite(bluePin2, 255);

analogWrite(redPin3, 255);
analogWrite(greenPin3, 255);// White RGB Light light 3 Right Side
analogWrite(bluePin3, 255);

analogWrite(redPin4, 255);
analogWrite(greenPin4, 255);// White RGB Light light 4 Right Side
analogWrite(bluePin4, 255);  

  delay(250);

analogWrite(redPin1, 200);
analogWrite(greenPin1, 20);// Pink RGB Light light 1 left Side
analogWrite(bluePin1, 100);

analogWrite(redPin2, 200);
analogWrite(greenPin2, 20);// Pink RGB Light light 2 Left Side
analogWrite(bluePin2, 100);

analogWrite(redPin3, 200);
analogWrite(greenPin3, 20);// Pink RGB Light light 3 Right Side
analogWrite(bluePin3, 100);

analogWrite(redPin4, 255);
analogWrite(greenPin4, 20);// Pink RGB Light light 4 Right Side
analogWrite(bluePin4, 100);    

  delay(10000);
  
digitalWrite(fx5, LOW);

  delay(150);
  
digitalWrite(fx5, HIGH);

  delay(300);
  
analogWrite(redPin1, 255);
analogWrite(greenPin1, 255);// White RGB Light light 1 left Side
analogWrite(bluePin1, 255);

analogWrite(redPin2, 255);
analogWrite(greenPin2, 255);// White RGB Light light 2 Left Side
analogWrite(bluePin2, 255);

analogWrite(redPin3, 255);
analogWrite(greenPin3, 255);// White RGB Light light 3 Right Side
analogWrite(bluePin3, 255);

analogWrite(redPin4, 255);
analogWrite(greenPin4, 255);// White RGB Light light 4 Right Side
analogWrite(bluePin4, 255); 

  delay(250);

analogWrite(redPin1, 10);
analogWrite(greenPin1, 10);// Blue RGB Light light 1 left Side
analogWrite(bluePin1, 255);

analogWrite(redPin2, 10);
analogWrite(greenPin2, 10);// Blue RGB Light light 2 Left Side
analogWrite(bluePin2, 255);

analogWrite(redPin3, 10);
analogWrite(greenPin3, 10);// Blue RGB Light light 3 Right Side
analogWrite(bluePin3, 255);

analogWrite(redPin4, 10);
analogWrite(greenPin4, 10);// Blue RGB Light light 4 Right Side
analogWrite(bluePin4, 255); 
  
  delay(8000);
  
digitalWrite(fx4, LOW);
  
  delay(150);

digitalWrite(fx4, HIGH);

  delay(150);
  
analogWrite(redPin1, 255);
analogWrite(greenPin1, 255);// White RGB Light light 1 left Side
analogWrite(bluePin1, 255);

analogWrite(redPin2, 255);
analogWrite(greenPin2, 255);// White RGB Light light 2 Left Side
analogWrite(bluePin2, 255);

analogWrite(redPin3, 255);
analogWrite(greenPin3, 255);// White RGB Light light 3 Right Side
analogWrite(bluePin3, 255);

analogWrite(redPin4, 255);
analogWrite(greenPin4, 255);// White RGB Light light 4 Right Side
analogWrite(bluePin4, 255); 

  delay(250);
  
analogWrite(redPin1, 200);
analogWrite(greenPin1, 20);// Pink RGB Light light 1 left Side
analogWrite(bluePin1, 100);

analogWrite(redPin2, 200);
analogWrite(greenPin2, 20);// Pink RGB Light light 2 Left Side
analogWrite(bluePin2, 100);

analogWrite(redPin3, 200);
analogWrite(greenPin3, 20);// Pink RGB Light light 3 Right Side
analogWrite(bluePin3, 100);

analogWrite(redPin4, 255);
analogWrite(greenPin4, 0);// Pink RGB Light light 4 Right Side
analogWrite(bluePin4, 100); 

  delay(9000);

digitalWrite(fx5, LOW);

  delay(150);
  
digitalWrite(fx5, HIGH);

  delay(300);
  
analogWrite(redPin1, 255);
analogWrite(greenPin1, 255);// White RGB Light light 1 left Side
analogWrite(bluePin1, 255);

analogWrite(redPin2, 255);
analogWrite(greenPin2, 255);// White RGB Light light 2 Left Side
analogWrite(bluePin2, 255);

analogWrite(redPin3, 255);
analogWrite(greenPin3, 255);// White RGB Light light 3 Right Side
analogWrite(bluePin3, 255);

analogWrite(redPin4, 255);
analogWrite(greenPin4, 255);// White RGB Light light 4 Right Side
analogWrite(bluePin4, 255); 

  delay(250);

analogWrite(redPin1, 200);
analogWrite(greenPin1, 20);// Pink RGB Light light 1 left Side
analogWrite(bluePin1, 100);

analogWrite(redPin2, 200);
analogWrite(greenPin2, 20);// Pink RGB Light light 2 Left Side
analogWrite(bluePin2, 100);

analogWrite(redPin3, 10);
analogWrite(greenPin3, 10);// Blue RGB Light light 3 Right Side
analogWrite(bluePin3, 255);

analogWrite(redPin4, 10);
analogWrite(greenPin4, 10);// Blue RGB Light light 4 Right Side
analogWrite(bluePin4, 255); 

  delay(10000);

digitalWrite(fx3, LOW);
  
  delay(150);
  
digitalWrite(fx3, HIGH);

  delay(1050);
  
analogWrite(redPin1, 255);
analogWrite(greenPin1, 255);// White RGB Light light 1 left Side
analogWrite(bluePin1, 255);

analogWrite(redPin2, 255);
analogWrite(greenPin2, 255);// White RGB Light light 2 Left Side
analogWrite(bluePin2, 255);

analogWrite(redPin3, 255);
analogWrite(greenPin3, 255);// White RGB Light light 3 Right Side
analogWrite(bluePin3, 255);

analogWrite(redPin4, 255);
analogWrite(greenPin4, 255);// White RGB Light light 4 Right Side
analogWrite(bluePin4, 255); 
 
 delay(250);
 
analogWrite(redPin1, 10);
analogWrite(greenPin1, 10);// Blue RGB Light light 1 left Side
analogWrite(bluePin1, 255);

analogWrite(redPin2, 10);
analogWrite(greenPin2, 10);// Blue RGB Light light 2 Left Side
analogWrite(bluePin2, 255);

analogWrite(redPin3, 10);
analogWrite(greenPin3, 10);// Blue RGB Light light 3 Right Side
analogWrite(bluePin3, 255);

analogWrite(redPin4, 10);
analogWrite(greenPin4, 10);// Blue RGB Light light 4 Right Side
analogWrite(bluePin4, 255);  
  
delay(8000);

}

BTW, when you find yourself writing stuff like

int redPin1..
int redPin2 ..
int redPin3..
int redPin4

then it's really time to start looking at arrays. (It's also time to consider whether you can really waste so much RAM on values that are unlikely to trouble a "byte" variable)

Dang so I only have 6 PWM pins SO i have to figure out to limit it to 2 lighting strings which might be an issue since i need a total of 10 lights 5 for one half and 5 for the other. I think thats too many lights per pin since pin has a max of 40MA I think i was pushing it with 3 lights on a string for one pin... Grrrr. Any one know a way to add analog output pins to my project?

If you dump the delay()s, you could do it in software.

Please read this

or you can use SoftPWM Library on any pin
https://code.google.com/p/rogue-code/wiki/SoftPWMLibraryDocumentation

and use transstors or fets to get some serious current.

Or WS2812 Led strip / neopixels (those less are available in lots of form factors

Thanks BillHo! That arrival sheds light on how else I can do this :slight_smile: DrAzzy I can't use neopixle strips I'm using fiber optic fabric, I need to connect all the fiber optics in a section to super bright LED, also using side glow fiber optic cables as piping in the dress and need to hook those to LEDs too. Sewing is my expertise this is my only my third aurdino project ever lol sorry if my questions come off a little novice :slight_smile: I appreciate all your help and suggestions!!

After reading through all the material, I’m thinking it might be easier to switch to another board that has more PWM pins… Looking at the Mega Pro 5V. I don’t think I’m ready for the manual coding. It didn’t even occur to me there might be another board I can use with more PWM pins… DUH!!!

A very useful exercise is to look at the blink without delay example, then write some code to fade up and down the LED on pin 13.