Here is the working code. NOTE: this is just a sample.
const int sensor[] = {A0,A1,A2}; //number of inputs
int flagged[] = {0,0,0}; //must correspond with # of inputs
int Num=0;
void check(int Num);
void setup ()
{
Serial.begin (9600);
}
void loop ()
{
for(Num = 0; Num<=2/* change with inputs*/; Num++)
{
/*Serial.print("X: ");
Serial.print(analogRead(sensor[0]));
Serial.print("\t");
Serial.print("Y: " );
Serial.print(analogRead(sensor[1]));
Serial.print("\t");
Serial.print("Z: " );
Serial.print(analogRead(sensor[2]));
Serial.println();*/
check(Num);
}
}
void check(int Num)
{
if(analogRead(sensor[Num])==1023)//when variable resistance give value =1023 print 'x'
{
if(!flagged[Num] && Num == 0 /* change with inputs*/)
{
Serial.print("x"); //do if condition is true
Serial.println();
flagged[Num] = 1;
}
if(!flagged[Num] && Num == 1)
{
Serial.print("y");//do if condition is true
Serial.println();
flagged[Num] = 1;
}
if(!flagged[Num] && Num == 2 )
{
Serial.print("z");//do if condition is true
Serial.println();
flagged[Num] = 1;
}
delay (100);
}
else flagged[Num] = 0;
return;
}