I wrote some simple code... I want to add a 4th pot for controlling the overall birghtness of the led...
So I add a pot to analog pin 3, and it changes the total brightness of the lights... I dont wanna sound like im lazy, i just dont know how... im only 11...
Here is the original code... please add the lines of code for the brightnss pot... it would be hooked to analog pin 3.
Original Code:
int RledPin = 11;
int GledPin = 10;
int BledPin = 9;
int RpotPin = 0;
int GpotPin = 1;
int BpotPin = 2;
int Rval;
int Gval;
int Bval;
void setup()
{
pinMode(RledPin, OUTPUT);
pinMode(GledPin, OUTPUT);
pinMode(BledPin, OUTPUT);
}
void loop()
{
Rval = analogRead(RpotPin);
Rval = map(Rval, 0, 1023, 0, 255);
Gval = analogRead(GpotPin);
Gval = map(Gval, 0, 1023, 0, 255);
Bval = analogRead(BpotPin);
Bval = map(Bval, 0, 1023, 0, 255);
analogWrite(RledPin, Rval);
analogWrite(GledPin, Gval);
analogWrite(BledPin, Bval);
delay(10);
}