Hhow to i turn the output to an rgb led to hexadecimal colour
I'm trying to do a project where I have an RGB lamp with 3 potentiometers to control RGB and an LCD to show the colour that the led is displaying >:(
Hhow to i turn the output to an rgb led to hexadecimal colour
I'm trying to do a project where I have an RGB lamp with 3 potentiometers to control RGB and an LCD to show the colour that the led is displaying >:(
Sorry about that, here is the code so far
int redPin = 9;
int greenPin = 10;
int bluePin = 11;
int potPin_red = A0;
int potPin_green = A1;
int potPin_blue = A2;
int readValue_red;
int readValue_green; green LED
int readValue_blue; blue LED
int writeValue_red;
int writeValue_green;
int writeValue_blue;
void setup() {
pinMode(potPin_red, INPUT);
pinMode(potPin_green, INPUT);
pinMode(potPin_blue, INPUT);
pinMode(redPin,OUTPUT);
pinMode(bluePin,OUTPUT);
pinMode(greenPin, OUTPUT);
}
void loop() {
readValue_red = analogRead(potPin_red);
readValue_green = analogRead(potPin_green);
readValue_blue = analogRead(potPin_blue);
writeValue_red = (255./1023.)*readValue_red;
writeValue_green = (255./1023.)*readValue_green;
writeValue_blue = (255./1023.)*readValue_blue;
analogWrite(redPin,writeValue_red);
analogWrite(greenPin,writeValue_green);
analogWrite(bluePin,writeValue_blue);
}
Thanks for the help, really appreciate it!
You can have a look at bishift operations. It's a matter of shifting and adding. If done properly, that will give you e.g.
0x00102030
^ ^ ^ ^
| | | +--- blue (48)
| | +----- green (32)
| +------- red (16)
|
+--------- unused