Created
May 21, 2018 00:42
-
-
Save melPlett/8ce176a5727f56e2cba448e5df5581d8 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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