array

This statement follows an if conditional statement. That's why the curly braces at begin and end. Array has been pre declared setting it to 255. voltsarray[255]=0.. Array has been pre zero'd. So voltsarray[0] = 0. What am I missing pse. Say count = 0

{voltsarray[] = {count}};

I can post the if statement if necessary. This line immediately follows the if.

Please don't post snippets.

http://snippets-r-us.com/

int voltage = 0;
int count = 0;
int voltsarray[255] = {0} ;

void setup()
{
Serial.begin(9600);
for(int j=0;j>=255;j++)
voltsarray[j] = 0;

}
void loop()

{

voltage = analogRead( A0 ); // Read the voltage from the filter board Pin A0
if (( voltage <= 255 ) && (count <= 255))
{voltsarray[] = {count}
else {count= count + 1}
// voltsarray is the array. store voltage to array 0

{ //if count less than or equal to max array count 255
count = count + 1;
} // count is equal to count +1 so counter for array is now 1
else if (count >= 255)
{ //if count is greater than 255 then array is full
count = 0;
} //so array is full set counter to 0 get ready to analyze the array
delay(10);

// print total count to terminal. should be 255
//count can be changed to voltage to see input from A0 pin

Serial.println(count); //test

}

int voltsarray[] = {0} ;

This is an array containing one element. Why use an array then?

for(int j=0;j>=255;j++)
   voltsarray[j] = 0;

This won't run even once, and even if it did, it's useless.

voltsarray[] = {count}

Non sense

You are also missing some ; and }, also learn indent your code:

if ( ( voltage <= 255 ) && (count <= 255) )
{
    voltsarray[] = { count
}
else
{
    count = count + 1
}

It makes it easier to find mistakes.

What are you trying to do?

@stx38834: Please edit your post, select the code, and put it between [code] ... [/code] tags.

You can do that by hitting the "Code" button above the posting area (It looks like a scroll with < > inside it).

I seem to recall mentioning that before ...

if ( ( voltage <= 255 ) && (count <= 255) )
{
voltsarray[] = { count
}
else
{
count = count + 1
}

I don't understand missing some and?
The other code compiles and runs correctly. the section to zero the array does work fine. It is used in case the array occupied space might have a byte accidently. Also much more code follows this. This more or less an introduction with many things to follow. How do you indent? The tab feature doesn't work.

@stx38834:

Look, buddy, please read this:

How to use this forum

Please use code tags.

Read this before posting a programming question

The nobbc tag.

int  voltage = 0;
int  count = 0;
const int b = 255;
int voltsarray[b];
int analogValue = 0;
int x = 0;

void setup()
{
Serial.begin(9600);
for(int j=0;j<=255;j++)
   voltsarray[j] = 0;
}
void loop()
{
x = 0
     voltage = analogRead( A0 );               // Read the voltage from the filter board Pin A0
if (( voltage <= 255 ) && (count <= 255))
     {
       voltsarray[x] = voltage            //]This is the problem line
]     }
     else
     {count = count +1}
   }
x = x+1;
                                           // voltsarray is the array. store voltage to array 0
                                          //if count less than or equal to max array count 255
           if count >= 255
              {
              count = 0
            }
                                          //so array is full set counter to 0 get ready to analyze the array 
              delay(10); 
                                                  // print total count to terminal. should be 255
                                                  //count can be changed to voltage to see input from A0 pin while reading 255 times

 Serial.println(voltage);//test             
  
   
}

This statement follows an if conditional statement. That's why the curly braces at begin and end. Array has been pre declared setting it to 255. voltsarray[255]=0.. Array has been pre zero'd. So voltsarray[0] = 0. What am I missing pse. Say count = 0

{voltsarray[] = {count}};

As for tags, all of mine are expired and I don't want to get arrested. As for changing the code to html, I did and it didn't show up here. I would post again but my post hole digger is out of gas. As for my question it again goes unanswered. I suppose Ill write the code in a different way. .. I cant say thanks because everything is always addressed except for the problem.

stx38834:
voltsarray[255] = {count}

should be

int voltsarray[255] = {1,2,3,4,5,6,7,8,continue till you reach 255};

or

for (int count = 1;count <= 255; count++) {
int voltsarray[] = {count};
}

to call the first element in the array would be

voltsarray[0] would be 1

and the last

voltsarray[254] would be 255

at least that's what I think you are looking for
it is not at all clear what you are asking

By not calling out the # of elements here : voltarray[] doesnt the array size itself to the number of elements named

I just tried that code and you are right it didn't work, also the variable was local when it needs to be global

I also don't understand the code you posted as I too am just learning about arrays so I will study the link you posted.

can a for loop be used to name the elements in an array such as this one?

const byte ledPins[] = {3,4,5,6,7};

ok but how I cant get that to work

Instead of wasting your time and ours writing random nonsensical garbage, get an elementary c/c++ textbook and learn to get the basic language syntax right.

Maybe some examples would help. See if you can follow this:

byte pinsArray[] = {13,14,15,16,}; // 4 element array

int analogArray[256]; // array of 256 ints = 512 bytes

byte x; // use for a counter

void setup(){
pinMode (pinsArray[0],OUTPUT); // set D13 as output

Serial.begin(9600);

digitalWrite (pinsArray[0], HIGH); // turns on D13
delay (1000);
digitalWrite (pinsArray[0], LOW); // turns off D13
}
void loop(){
// take 256 readings, every 0.1 second
for (x=0; x<=255; x=x+1){
analogArray[x] = analogRead(A0); // take a reading and store it in the array.
delay (100);
}
for (x=0; x<=255; x=x+1){
Serial.print ("location ");
Serial.print (x); // print out the array element to be read
Serial.print ("value ");
Serial.println (analogArray[x]); // [print out the data at array location x
}

} // end loop

stx38834:
As for tags, all of mine are expired and I don't want to get arrested. As for changing the code to html, I did and it didn't show up here. I would post again but my post hole digger is out of gas.

Meaningless mumbo-jumbo.

As for my question it again goes unanswered. I suppose Ill write the code in a different way. .. I cant say thanks because everything is always addressed except for the problem.

We seem to be in a parallel universe. You post nonsense, we try to help you, you post more nonsense.

stx38834:
As for tags, all of mine are expired and I don't want to get arrested.

You got told you use the tags. When you did that, people started looking at your code.

As for my question it again goes unanswered.

That's because people are giving you what you need, not what you want.

So let's try to address your actual question:

What am I missing pse

You are missing that braces are used to delimit a statement list so that syntactically it become a single statement. You have put braces inside an assignment expression, which is nonsense and means nothing and will not compile.

Here's a link to a EBNF grammar for C: http://www.cs.man.ac.uk/~pjj/bnf/c_syntax.bnf . You are trying to match the code {voltsarray[] = {count}}; to the production stat.

stat
-> compound-stat
-> '{' stat-list '}' (there's your first pair of braces)
-> stat
-> exp_stat
-> exp ';' (here's your first error. No semicolon terminating the expression.)
-> assignment_exp
-> unary_exp assignment_operator assignment_exp
--> unary_exp is voltsarray[], (Here's your second error. No expression in the brackets.)
--> assignment_operator is '='
--> assignment_exp you are trying to have as {count}, which just makes no sense whatever.

Did you understand that?

Of course not. That's why people have not been answering your question - it's obvious that you would not understand the answer. Instead they have been trying to help you. Maybe you should read that link.

CrossRoads:
Maybe some examples would help. See if you can follow this:

Maybe he didn't but I sure did glad I jumped in.
Thanks