Home \ Help \ Search \ Login RSS

Welcome, Guest. Please Login

This forum is now READ-ONLY! Please visit http://forum.wiring.co/ for the new forum.

Wiring ForumProgramming Questions & HelpPrograms › passing array

Page Index Toggle Pages: 1
passing array (Read 4029 times)
01/11/09 at 16:54:00

showup   Offline
YaBB Newbies

Posts: 8
*
 
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.
 
IP Logged
 
Reply #1 - 01/30/09 at 06:44:39

barragan   Offline
YaBB Administrator

Posts: 939
*****
 
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.
 
IP Logged
 
Page Index Toggle Pages: 1