Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
int redPot;
int RedGB;
int redLED;
int greenPot;
int RGreenB;
int greenLED;
int bluePot;
int RGBlue;
int blueLED;
void setup() {
Serial.begin(9600);
pinMode(3, OUTPUT); // Red RGB
pinMode(5, OUTPUT); // Green RGB
pinMode(6, OUTPUT); // Blue RGB
pinMode(9, OUTPUT); // red led
pinMode(10, OUTPUT); // green led
pinMode(11, OUTPUT); // blue led
}
void loop() {
redPot = analogRead(A2);
greenPot = analogRead(A1);
bluePot = analogRead(A0);
Serial.print("redPot:");
Serial.print(redPot);
Serial.print("greenPot:");
Serial.print(greenPot);
Serial.print("bluePot:");
Serial.println(bluePot);
//delay(1000); //uncomment to read Pot values
RedGB = map(redPot, 0, 1023, 0, 255);
analogWrite(3, RedGB);
redLED = map(redPot,0, 1023, 0, 255);
analogWrite(9, redLED);
RGreenB = map(greenPot, 0, 1023, 0, 255);
analogWrite(5, RGreenB);
greenLED = map(greenPot, 0, 1023, 0, 255);
analogWrite(10, greenLED);
RGBlue = map(bluePot, 0, 1023, 0, 255);
analogWrite(6, RGBlue);
blueLED = map(bluePot, 0, 1023, 0, 255);
analogWrite(11, blueLED);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment