multiple ir sensors FOR loop

I found a piece of code on youtube where one sensor is being used for sending Midi messages. I was wondering how this van be done using more in a FOR loop. i fighting with the brackets and kind of lost. got a lot of errors.

int sens;
void loop(){
  for(int i=0;i<16;i++){
  sens[i] = 1027 - analogRead(i);
  if(sens[i]<870){
     if(!playing)noteOn();
     else {
          trackNote(sens[i]);
     }
  }
  else {
    if(playing) noteOff();
     }
  }
}

Does anyone know what best approach is ?

i fighting with the brackets and kind of lost. got a lot of errors.

You need to declare an array of sensors but as you have not posted a full sketch or any of the error messages it is difficult to provide any help

Please follow the advice on posting code given in Read this before posting a programming question in order to make your sketch easy to read, copy and test

In particular note the advice to Auto format code in the IDE and to use code tags when posting code here as it prevents some combinations of characters in code being interpreted as HTML commands such as italics, bold or a smiley character, all of which render the code useless

If the code exceeds the 9000 character inline limit then attach it to a post

This topic was automatically closed 120 days after the last reply. New replies are no longer allowed.