If you have multiple input then yes, you need to distiguish them.
const int sensor[0] = A0;
const int sensor[1] = A1;
const int sensor[2] = A2; // analog input use variable resistance
int flagged1, flagged2, flagged3 = 0;
void check(int Num);
void setup ()
{
Serial.begin (9600);
}
void loop ()
{
for(Num = 0; Num<3; Num++)
{
check(Num);
}
}
void check(int Num)
{
if(analogRead(sensor[Num])==1023)//when variable resistance give value =1023 print 'x'
{
if(!flagged1 && Num == 0)
{
Serial.print("x");
Serial.println();
flagged1 = 1;
}
else flagged1 = 0;
if(!flagged2 && Num == 1)
{
Serial.print("y");
Serial.println();
flagged2 = 1;
}
else flagged2 = 0;
if(!flagged3 && Num == 2 )
{
Serial.print("z");
Serial.println();
flagged3 = 1;
}
else flagged3 = 0;
delay (100);
}
return;
}
Let me check if this works or not.
Something like this, but maybe not as hectic.