-2
int sensorArray[32] ;
int selectPinZero = 8;
int selectPinOne = 9;
int selectPinTwo = 10;
int selectpinthree=11;
int Enablepin=7;

int inputPinOne = 0;
int inputPinTwo = 1;



int sensor1;
int sensor2;
int voltage1;
int voltage2;
int Current_Sensor1[16];
int Current_Sensor2[16];
int row;
int column;

int array[17][5]={
                    {0,0,0,0,0},
                    {0,0,0,0,1},
                    {0,0,0,1,0},  
                    {0,0,0,1,1},
                    {0,0,1,0,0},
                    {0,0,1,0,1},
                    {0,0,1,1,0},
                    {0,0,1,1,1},
                    {0,1,0,0,0},
                    {0,1,0,0,1 },
                    {0,1,0,1,0},
                    {0,1,0,1,1},
                    {0,1,1,0,0 },
                    {0,1,1,0,1},
                    {0,1,1,1,0 },
                    {0,1,1,1,1}, 
                    {1,0,0,0,0} 
                 };


unsigned long StopTime=0;
int Counter=0;

void setup(){

  Serial.begin(9600);
  pinMode(selectPinZero, OUTPUT);
  pinMode(selectPinOne, OUTPUT);
  pinMode(selectPinTwo, OUTPUT);
  pinMode(selectpinthree,OUTPUT);

  pinMode(inputPinOne, INPUT);
  pinMode(inputPinTwo, INPUT);
}


void loop()
{

  for(row=0;row<17;row++)
  {

    digitalWrite(Enablepin,array[row][0]);
    digitalWrite(selectPinZero,array[row][1]);
    digitalWrite(selectPinOne,array[row][2]);
    digitalWrite(selectPinTwo,array[row][3]);  
    digitalWrite(selectpinthree,array[row][4]);  
    sensor1=analogRead(inputPinOne);
    sensor2=analogRead(inputPinTwo);
    voltage1=sensor1 * ARDUINO_ANALOG_SCALING;
    voltage2=sensor2* ARDUINO_ANALOG_SCALING;
    Current_Sensor1[row]=(10*voltage1)-25;
    Current_Sensor2[row]=(10*voltage2)-25;
    Serial.print("Currentsensor1:");
    Serial.println( Current_Sensor1[row]);
    Serial.print("Currentsensor2:");
    Serial.println( Current_Sensor2[row]);
     Counter=Counter+1;
    Serial.print("Counter:");
    Serial.println(Counter);
    Serial.println(".......................");
        delay(1000);


     }
}

Here is my Arduino code. I wanted to activate Digital pin for every 1000ms delay.

During each delay the analog value should be stored in an array of index.

I don't know how to keep track of analog value read, or from which port I am reading. I could flicker the LED on the hardware side but it doesn't make any sense. Any method you can suggest here?

Application:

I have 32 hall sensors connected via mux circuit. I wanted to know which sensor is reading value. I want any idea to might suggest to me to keep track here.

1

You should download timer1 library from http://playground.arduino.cc/Code/Timer1

Init timer1 with a value of 1000000 and it will perform an overflow every second. On every overflow it will perform an action, put your code to activate a pin there. And do the serial readings in your loop.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.