Wiring Forum
Programming Questions & Help >> Programs >> passing array

Message started by showup on 01/11/09 at 16:54:00

Title: passing array
Post by showup on 01/11/09 at 16:54:00
What is the easy way to pass an array to a subroutine and receive an array from subroutine with wiring environment?

I would appreciate an example.

Title: Re: passing array
Post by barragan on 01/30/09 at 06:44:39
you can do it like this:

void drawFrame(byte frame[8][16]) {
 for(int i=0; i<8; i++) {
   for(int j=0; j<16; j++) {
     if(frame[i][j] == 1) {
       digitalWrite(j, HIGH); //just as example
     else {
       digitalWrite(j, LOW);

the above example passes a two-dimensional array to a function, and uses the data to set some pins accordingly.

Wiring Forum » Powered by YaBB 2.5 AE!
YaBB Forum Software © 2000-2010. All Rights Reserved.