Hey everyone,
I was just wondering how hexadecimal is handled in arrays. It doesn't seem to handle them like I would have thought and there doesn't seem to be much on this topic. So I've got a simple 4 led row setup. In my array I have binary "data counting up. When I try to replace the binary with hex "data" i've already tried them as 0x00,0x01... and I can't seem to figure it out. The code is below. I'd just much rather be using Hex to store in memory rather than binary because I'm working on just making my own POV.
int pins[] = {9,10,11,12}; // an array of pin numbers
int col_len = 4; // column lenght
// customizable parameters
int timer1 = 1000; // time between columns
int timer2 = 0; // time between frames
int timer3 = 0; // time between drawings
int frame_len = 4; // frame length
int frame_num = 1; // number of frames
// data corresponding to the image to be displayed
int data[] = {0x0,0x1,0x2,0x3,0x4,0x5,0x6,0x7,0x8,0x9,0xA,0xB,0xC,0xD,0xE,0xF};
void setup()
{
int i;
for (i = 0; i < col_len; i++)
pinMode(pins[i], OUTPUT); // set each pin as an output
}
void loop()
{
int a,b,c;
// go through all data for all columns in each frame.
for (a = 0; a < frame_num; a++)
{
for (b = 0; b < frame_len; b++)
{
for (c = 0; c < col_len; c++)
{
if (data[a*frame_len*col_len + b*col_len + c] == 0) {digitalWrite(pins[c], LOW);}
else {digitalWrite(pins[c], HIGH);}
}
delay(timer1);
}
for (c = 0; c < col_len; c++)
{digitalWrite(pins[c], LOW);}
delay(timer2);
}
delay(timer3);
}