void loop()
{
String color = "4b0088";
setColor(0x4b , 0x00 , 0x88);
}
void setColor(int red, int green, int blue)
{ #ifdef COMMON_ANODE
red = 255 - red;
green = 255 - green;
blue = 255 - blue; #endif
analogWrite(redPin, red);
analogWrite(greenPin, green);
analogWrite(bluePin, blue);
}
As you can see there is ¨stringcolor¨and i want that arduino will read this stringcolor for example ¨4B0088¨and break it into pieces ant those piceces should be seted in the line under like 0x4B 0x00 0x88
I am begginer by programming but i would like to make my apprenticeship in this content
Thx for help
void loop()
{
char color[] = "4b0088";
long val = strtol(color, NULL, 16);
byte r, g, b;
r = val >> 16;
g = val >> 8;
b = val;
}
void setColor(int red, int green, int blue)
{ #ifdef COMMON_ANODE
red = 255 - red;
green = 255 - green;
blue = 255 - blue; #endif
analogWrite(redPin, red);
analogWrite(greenPin, green);
analogWrite(bluePin, blue);
}
but the led is not turned on... Maybe i made a mistake, it can be possible, as i said, i im using arduino since yesterday morning
Maybe it does not work for me because i am not using the original arduino... Rf duino is the platform i use... I got it from my employer to learn how to programm
Some of codes made for arduino dont work for me