Counting multiple pulse input


I am writing some code that reads the pluseIn() function to start a counter for each of two rotary encoders and then send the data through serial. However, if one of the encoders is currently reading, the other one won’t read. If I plug one encoder in both pins, it works normally.

here’s my code:

#include <StopWatch.h> //stopwatch class
stopW1 StopWatch;

int val0,val1,count0,count1 = 0
unsigned long lastSent = 0;
void setup()

void loop()
// I had to use the analog pins due to limitations on the board, all the digital inputs have an opto-isolator
val0 = pulseIn(A0, HIGH); 
val1 = pulseIn(A1, HIGH);
if(val0 != 0)
count0 ++;
if(val1 != 0)
count1 ++;
if(stopW1.elapsed() - lastSent > 500)
lastSent =  stopW1.elapsed();

Serial.println("count 0: ")
Serial.print(" count 1: ");

Solved it ! I found this hope someone finds it useful.

Use INTx or PCINTx.

Can you post your final working code for future reference?