int rPin=D16;
int gPin=D15;
int bPin=A5;
int rMax = 255; // Full brightness for an Cathode RGB LED is 0, and off 255
int gMax = 255; // Full brightness for an Cathode RGB LED is 0, and off 255
int bMax = 255; // Full brightness for an Cathode RGB LED is 0, and off 255
int rLum = 0;
int gLum = 0;
int bLum = 0;
int potPinR = A2;
int potPinG = A1;
int potPinB = A0;
// Create a variable to hold the pot reading
int potRdgR = 0;
int potRdgG = 0;
int potRdgB = 0;
void setup()
{
// Set up our pins for output
pinMode(rPin, OUTPUT);
pinMode(gPin, OUTPUT);
pinMode(bPin, OUTPUT);
// turn them all off...
analogWrite(rPin, rMax);
analogWrite(gPin, gMax);
analogWrite(bPin, bMax);
// pot reading
Particle.variable("potR",potRdgR);
Particle.variable("potG",potRdgG);
Particle.variable("potB",potRdgB);
}
void loop()
{
potRdgR = analogRead(potPinR);
potRdgG = analogRead(potPinG);
potRdgB = analogRead(potPinB);
rLum = map(potRdgR,0,4095,0,255);
gLum = map(potRdgG,0,4095,0,255);
bLum = map(potRdgB,0,4095,0,255);
analogWrite(rPin, 255-rLum);
analogWrite(gPin, 255-gLum);
analogWrite(bPin, 255-bLum);
delay(100);
}
Click to Expand
Content Rating
Is this a good/useful/informative piece of content to include in the project? Have your say!
You must login before you can post a comment. .