# Global variable in for loop

I don’t know how to research whether I can do this or not, so any help (an answer or a site that would help) would be appreciated!

Basically, I want to do this:

Int thing1
Int thing2
int thing3

For (i=1, i++, i<3) {analogRead (Pin(i))=thing(i)}

Would this result in reading pin 1, 2 and 3, and then storing their respective values to the ints thing1, thing 2, and thing 3?

Time to study ARRAYS:
https://www.arduino.cc/reference/en/language/variables/data-types/array/

Kerias:
Would this result in reading pin 1, 2 and 3, and then storing their respective values to the ints thing1, thing 2, and thing 3?

No, what you need here is an array

``````int thing;
``````

Kerias:
For (i=1, i++, i<3) {analogRead (Pin(i))=thing(i)}

be carefull with this, this code will only read inputs from pin 1 and 2, you have whether to put

``````i<=3
``````

, or

``````i<4
``````
``````For (i=1, i++, i<3)
``````

That is wrong for a couple of reasons. Don’t capitalize for, and it should be

``````(i = 1; i < 3; i++)
``````

initialize, compare, increment is the order.

A short sketch to illustrate using arrays.

``````int thing;
const byte pins[] = {A1, A2, A3};

void setup()
{
Serial.begin(9600);

for(int i = 0; i < 3; i++)
{

Serial.print(" Thing ");
Serial.print(i);
Serial.print("  =  ");
Serial.println(thing[i]);
}
Serial.println();
}

void loop()
{

}
``````

Also

``````thing[i] = analogRead(Pin[i]);
``````

Thank you all so much for the help! I'll definitely work on fixing my grammar and using arrays, sorry it's been quite some time since I've used Arduino