How to implement edge response function without interruption

Igor_K

Member
Hi everyone,.
Please help with code. It is necessary to output data from the matrix synchronously to the fronts of the incoming pulses. Such a function is implemented on RASBER RI "GPIO.wait_for_edge(6,GPIO.RISING)". I wrote my own version of such an implementation of the function, but for some reason one impulse is skipped along the rows ( if (digitalRead(8) == 1). Maybe there are functions and subtle mechanisms of similar implementation for Arduino Ide? Below is my code
Thanks in advance for the community's support.

Code:
 // displaying element values  
  for (int i = 0; i < rows; i++) {
    if (digitalRead(8) == 1)
    {
     
        for (long j = 0; j < cols; j++) {
          bool bitValue = (byteMatrix[i][j / 8] >> (7 - j % 8)) & 1;
        //  bool a = digitalRead(5);
         // if (a == 1 && b == 1)
          if (digitalRead(5) == 1)
          {
             digitalWrite(2, bitValue);
          }
    
          pulseIn(5, LOW);
          //delayMicroseconds(10);      // pauses in microseconds
        //  while (in1 != 1)
       //   {
       //      in1 = digitalRead(5);
       //   } 
           
        }
     }
     pulseIn(8, LOW);
   //  delayMicroseconds(10);      // pauses in microseconds
  }
  
}

void loop() {
  // 
}
 
This sequence of code will wait for the rising edge on pin 8.
Code:
  // If the pin is already HIGH
  if(digitalRead(8)) {
    // wait for it to go lOW
    while(digitalRead(8) == 1);
  }
  // The pin is now LOW, wait for it to go HIGH
  while(digitalRead(8) == 0);
  // The pin has just gone HIGH (leading edge)

Pete
 
Back
Top