Hi!
I am very very new to playing with Arduino code. I’m currently trying to do something that seems quite simple. I have a standard (non-addressable) strip of 12v RGBWs. I’ve successfully set up and Uno and the breadboard with a 5K pot for each color channel. That works great. Now, I’d love to pulse the single color I’ve dialed in with the pots. Pretty much every code scenario I can think to try either overrides the pot output and pulses all channels simultaneously or pulses four different combinations of channels in a set and starts over. Any help would be greatly appreciated. Below is the code I used:
int const rPotPin = A2;
int const gPotPin = A1;
int const bPotPin = A0;
int const wPotPin = A3;
int const rOutPin = 3;
int const gOutPin = 5;
int const bOutPin = 6;
int const wOutPin = 9;
int rVal;
int gVal;
int bVal;
int wVal;
int fadeAmount = 5;
int brightness1 = 0;
int brightness2 = 0;
int brightness3 = 0;
int brightness4 = 0;
void setup()
{
pinMode(rOutPin, OUTPUT);
pinMode(gOutPin, OUTPUT);
pinMode(bOutPin, OUTPUT);
pinMode(wOutPin, OUTPUT);
}
void loop()
{
rVal = analogRead(rPotPin) / 4;
gVal = analogRead(gPotPin) / 4;
bVal = analogRead(bPotPin) / 4;
wVal = analogRead(wPotPin) / 4;
analogWrite(rOutPin, rVal);
analogWrite(gOutPin, gVal);
analogWrite(bOutPin, bVal);
analogWrite(wOutPin, wVal);
// the following is the unsuccessful addition to try and
//pulse the settings for each channel (simultaneously)
//at their dialed in output throught the pots/analog pins
analogWrite(rVal, brightness1);
analogWrite(gVal, brightness2);
analogWrite(bVal, brightness3);
analogWrite(wVal, brightness4);
brightness1 = brightness1 + fadeAmount;
if (brightness1 <= 0 || brightness1 >= rVal) {
fadeAmount = -fadeAmount;
};
brightness2 = brightness2 + fadeAmount;
if (brightness2 <= 0 || brightness2 >= gVal) {
fadeAmount = -fadeAmount;
};
brightness3 = brightness3 + fadeAmount;
if (brightness3 <= 0 || brightness3 >= bVal) {
fadeAmount = -fadeAmount;
};
brightness4 = brightness4 + fadeAmount;
if (brightness4 <= 0 || brightness4 >= wVal) {
fadeAmount = -fadeAmount;
}
// wait for 30 milliseconds to see the dimming effect
delay(30);
}