Pages: [1]   Go Down
Author Topic: Array?  (Read 432 times)
0 Members and 1 Guest are viewing this topic.
0
Offline Offline
Newbie
*
Karma: 0
Posts: 1
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

I want to read pin values and put them in a "buffer". My program is like this:

int buffer[361] = 0;
void setup()
{...}
void loop()
{
   for(int i=0;i<361;i++)
     {
          buffer=analogRead(pinNumber);
      }
...
}

But it seems the values can not be written into the array, and some members of the array even have very absurd values. If I output the values of the pins directly then everything is fine. The problem is that they can't be written into the array.
« Last Edit: November 27, 2006, 09:45:58 am by hsj » Logged

0
Offline Offline
Newbie
*
Karma: 0
Posts: 49
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Your only reading one pin at a time. and placing it into your array.  then advancing your array.

You would need a more sophisticated loop within a loop and add the values of each pin according to their position.

Or better yet, read all pins at once and place that value into your array.

Follow the link to read all pins at once  (actually the register to where they lay)

http://www.arduino.cc/cgi-bin/yabb2/YaBB.pl?num=1160606668

ñ
Logged

Forum Administrator
Cambridge, MA
Offline Offline
Faraday Member
*****
Karma: 9
Posts: 3538
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

You might try removing the = 0 from the line declaring the array, or replacing it with = { 0 } .  Otherwise, you might try making the array smaller, as it's possible there's not enough RAM for that many elements.
Logged

Pages: [1]   Go Up
Jump to: