Zero Crossing multiple signals

Hello everyone
I am doing a circuit to read three different frequencies but in the code I can only make me read one of the frequencies how could I fix the interruptions so I read the other two frequencies? because what I see that performs is reading only the pin 2 and not the other how can you fix that?

Please post your code again, but this time correctly. In the IDE, press Ctrl-T, then copy the code into a new post using code tags so it looks likethis.

I think that when you see your code properly indented, you will see one of the problems: your { and } do not match. Another useful way to spot these problems is to put the cursor next to a }. The matching { will be highlighted and vice versa (if there is a matching one).

int contador=0;
unsigned long  LastConnectionTime=millis();
const unsigned long postingInterval1 = 1L * 1000L;
int Tiempo=0;
void setup() {
Serial.begin(9600);

}

void loop() {
  
    pinMode(2,(INPUT_PULLUP));
   attachInterrupt(0,Zero_Cross,FALLING);
  Serial.println(millis());
  if (millis() - LastConnectionTime > postingInterval1){
    Serial.print("Frecuencia 1: ");
    Serial.print(contador/3);
    Serial.print(" ");
    Serial.println("Hz");
    LastConnectionTime= millis();
    contador=0;
    
     }
  }
  
    pinMode(3,(INPUT_PULLUP));
  attachInterrupt(0,Zero_Cross,FALLING);
  if (millis() - LastConnectionTime > postingInterval1){
    Serial.print("Frecuencia 2: " );
    Serial.print(contador/3);
    Serial.print(" ");
    Serial.println("Hz");
    LastConnectionTime= millis();
    contador=0;
    }
  }
  pinMode(18,(INPUT_PULLUP));
  attachInterrupt(0,Zero_Cross,FALLING);
  if (millis() - LastConnectionTime > postingInterval1){
    Serial.print("Frecuencia 3: " );
    Serial.print(contador/3);
    Serial.print(" ");
    Serial.println("Hz");
    LastConnectionTime= millis();
    contador=0;
    }
  }
  delay(3000);
}

void Zero_Cross()
{contador ++;}

See my previous suggestion about using Ctrl-T. I guess you are trying to do the formatting/indentation by hand (on a phone?)

:o :o nop but I can usining ctrl -T it generates another sale in the browser help me i new

Hi,

Do the CTRL-T in the IDE where you wrote your code.

NOT the browser.

Tom.. :slight_smile: