74HC259, Compiling Error...


code: [select]
boolean hc259_address[] = {0,0,0};  // sets 3-bit address array
boolean hc259_data[] = {0,0,0,0,0,0,0,0};  // sets 8-bit data array

// define latch address pins , data pin
int hc259_a_pin = 4;
int hc259_b_pin = 3;
int hc259_c_pin = 2;
int hc259_data_pin = 5;

void setup()
{
 pinmode(hc259_a_pin, output);
 pinmode(hc259_b_pin, output);
 pinmode(hc259_c_pin, output);
 pinmode(hc259_data_pin, output);
}

void loop()
{

 hc259_data[] = {0,1,0,1,0,1,0,1};
 hc259_send_data();  // send 01010101 chip, lighting leds 2, 4, 6, , 8
 delay(1000);
 hc259_data[] = {1,0,1,0,1,0,1,0};
 hc259_send_data();  // send 10101010 chip, lighting leds 1, 3, 5, , 7
 delay(1000);

}

void hc259_send_data()  // takes data hc259_data[] , sends it, bit bit, each bit register in hc259
{

 for (i = 0; <= 7; ++) // each array element
 {
   hc259_set_address(i);  // choose right pin
   digitalwrite(hc259_data_pin,hc259_data[i]);  // send bit stored on pin
 }

}

void hc259_set_address(int latch)  // translates input between 0 , 7 correct bit sequence send latch registers, addressing desired pin
{

 switch (latch)
 {

   case 0:
     hc259_address[] = {0,0,0}
     break;
   case 1:
     hc259_address[] = {0,0,1}
     break;
   case 2:
     hc259_address[] = {0,1,0}
     break;
   case 3:
     hc259_address[] = {0,1,1}
     break;
   case 4:
     hc259_address[] = {1,0,0}
     break;
   case 5:
     hc259_address[] = {1,0,1}
     break;
   case 6:
     hc259_address[] = {1,1,0}
     break;
   case 7:
     hc259_address[] = {1,1,1}
     break;
   default:
     // nothing

 }

 // send data latch pins tell bit address
 digitalwrite(hc259_a_pin,hc259_address[0]);
 digitalwrite(hc259_b_pin,hc259_address[1]);
 digitalwrite(hc259_c_pin,hc259_address[2]);

}

that's i've got.  when try compile, gives me error:

code: [select]
in function 'void loop()':
error: expected primary-expression before ']' token in function 'void hc259_send_data()':
in function 'void hc259_set_address(int)':


what heck mean?  as far experience c/c++ , php has shown me, i've done correct.  did make stupid beginner mistake, or limitation of arduino wasn't aware of?

thanks!

code: [select]
hc259_address[] = {0,0,0} [glow]  [/glow]
code: [select]
hc259_data[] = {0,1,0,1,0,1,0,1};

quote
i've done correct

hmmm.

quote
is limitation of arduino wasn't aware of?

no, that's lack of understanding of c/c++.


Arduino Forum > Forum 2005-2010 (read only) > Software > Syntax & Programs > 74HC259, Compiling Error...


arduino

Comments

Popular posts from this blog

CAN'T INSTALL MAMBELFISH 1.5 FROM DIRECTORY - Joomla! Forum - community, help and support

error: expected initializer before 'void'

CPU load monitoring using GPIO and leds - Raspberry Pi Forums