The serial monitor give what I expect, a value from 0 to 255 while potentiometer is totally turned off or totally turned on.
The problem is "in the real life" because 1 color never change with different position of the potentiometer (the other 2 colors work perfectly).
I don't understand why, I've also tried a simple configuration connecting directly each color of the strip with arduino, but same problem.
I've also tried changing the potentiometer with a new one but nothing.
it seems that 1 digital pin output is always at max
Any idea?
Not all the pins you have chosen are capable of PWM outputs. Look at your board if the pin number has a ~ next to it you can use it with analogWrite, otherwise you can't.
The board is an arduino UNO so if i'm correct the pwm ports are 3-5-6-9-10-11
about
int r, g, b; you're right,
The code was a little different in the first version because I've used 4 potentiometer and the last one was used to make a crosscolorfader effect if >20 and the potentiometer value was used to select the speed of fading. But I' had the same problem while using the rgb selectors so I've deleted the code of the 4th potentiometer but i've missed the r,g,b declaration for the crosscolorfader for cycles.
About which colors are which...
rpin -->redpin-->pin 10 digital output
gpin -->greenpin--> pin 11 digital output
bpin -->bluepin --> pin 3 digital output
The problem is on the green, but if i change the cable on the digital pin with another color I've the same problem with the new color. (indeed).
Hope to be more "understandable" in this post.
I've find short circuit on the link of the green color.
Now everything works correctly.
Sorry for the inconvenience.
I'll post the code for RGB color chooser + Cross colorfader with potentiometer for fadertime hope to be useful to someone.
#define REDPIN 10
#define GREENPIN 11
#define BLUEPIN 3
int faderPin = 0;
int rPin = 2;
int gPin = 3;
int bPin = 4;
int fadeSpeed=0;
int r,g,b ;
void setup() {
pinMode(REDPIN, OUTPUT);
pinMode(GREENPIN, OUTPUT);
pinMode(BLUEPIN, OUTPUT);
}
void loop() {
if (analogRead(faderPin)>20){
fadeSpeed = analogRead(faderPin);
analogWrite(REDPIN, 0);
analogWrite(BLUEPIN, 255);
analogWrite(GREENPIN, 0);
// fade from blue to violet
for (r = 0; r < 256; r++) {
analogWrite(REDPIN, r);
fadeSpeed = analogRead(faderPin);
delay(fadeSpeed);
}
// fade from violet to red
for (b = 255; b > 0; b--) {
analogWrite(BLUEPIN, b);
fadeSpeed = analogRead(faderPin);
delay(fadeSpeed);
}
// fade from red to yellow
for (g = 0; g < 256; g++) {
analogWrite(GREENPIN, g);
fadeSpeed = analogRead(faderPin);
delay(fadeSpeed);
}
// fade from yellow to green
for (r = 255; r > 0; r--) {
analogWrite(REDPIN, r);
fadeSpeed = analogRead(faderPin);
delay(fadeSpeed);
}
// fade from green to teal
for (b = 0; b < 256; b++) {
analogWrite(BLUEPIN, b);
fadeSpeed = analogRead(faderPin);
delay(fadeSpeed);
}
// fade from teal to blue
for (g = 255; g > 0; g--) {
analogWrite(GREENPIN, g);
fadeSpeed = analogRead(faderPin);
delay(fadeSpeed);
}
}
else {
analogWrite(GREENPIN, analogRead(gPin)/4);
analogWrite(BLUEPIN, analogRead(bPin)/4);
analogWrite(REDPIN, analogRead(rPin)/4);
delay(300);
}
}
If someone has something to suggest feel free to write
Now that you have found the answer how about posting that code correctly using code tags. Read the how to use the forum pages sticky.
Then modify your post to get it right.
Did you check to see if the value displayed in the serial monitor is decimal and not ascii?
can you change colors with software values instead of analog voltages?
Now that you have found the answer how about posting that code correctly using code tags. Read the how to use the forum pages sticky.
Then modify your post to get it right.