hı I have an array which includes colors and when ı try to access values by index, ı got integer values
for below code I got
22:07:57.458 -> 31727
which is not related to my color value
#define BLACK 0x0000
#define NAVY 0xBDD6
#define DARKGREEN 0x03E0
#define DARKCYAN 0x03EF
#define MAROON 0x0CF3
#define PURPLE 0x780F
#define OLIVE 0xB383
#define LIGHTGREY 0xC618
#define DARKGREY 0x7BEF
#define BLUE 0x001F
#define GREEN 0x07E0
#define CYAN 0x07FF
#define RED 0xF800
#define MAGENTA 0xF81F
#define YELLOW 0xFFE0
#define WHITE 0xFFFF
#define ORANGE 0xFD20
#define GREENYELLOW 0xAFE5
int allColor[] = {DARKGREY,MAGENTA,GREENYELLOW,BLUE,OLIVE,ORANGE,BLACK};
void setup() {
// put your setup code here, to run once:
Serial.begin(9600);
Serial.print(allColor[0]);
}
void loop() {
// put your main code here, to run repeatedly:
}
Your program printed
allcolor[0]
allcolor[0] is dark gray
dark grey is 0x7BEF
0x7BEF is 31727 in decimal.
So what’s you problem?
HTH
a7
Maybe you were expecting to see the value in hex?
void setup() {
// put your setup code here, to run once:
Serial.begin(9600);
Serial.println(allColor[0]);
Serial.println(allColor[0], HEX);
}
void loop() {
}
31727
7BEF
for Serial.println(allColor[0]); or Serial.println(allColor[0], HEX); I expect to get 0x7BEF value but the values I got different
I understand that Serial.println(allColor[1], HEX); gives last two number of my value and all values start with 0x. What about 3th and 4th number?
how your second print code give 7BEF ? for me it print just EF and I checked for other index it gives me just last two number
akardas16:
how your second print code give 7BEF ? for me it print just EF and I checked for other index it gives me just last two number
Did you change the definition of allColor[]?