PulseIn function not working

When I am using XOR gate to generate the pulse and the output of XOR gate is connected to Pin 13, it just prints zero. The output of XOR gate is shown as attachment.

#include <LiquidCrystal.h>
int pin = 13;
float rads = 57.29577951; 
float degree = 360;
float frequency = 50;
float nano = 1 * pow (10,-6); 
float angle;

int ctr;

void setup()
{
 pinMode(pin, INPUT);
 Serial.begin(9600);
 lcd.begin(16, 2);

}
void loop()
{
 
for (ctr = 0; ctr <= 4; ctr++) // Perform 4 measurements then reset
 {
 angle = ((((pulseIn(pin, HIGH)) * nano)* degree)* frequency);
Pulse_value = pulseIn(pin,HIGH);
  Serial.print(Pulse_value, 2);
  Serial.print("//");
}

Output:
0.00//0.00//0.00//0.00//0.00//0.00

test.JPG

test.JPG

Is this on a real Arduino or a simulator?

Put serial prints at each stage of the calculation to see if it is working like you think.

A schematic is more meaningful that one of those fritz type diagrams.

Where is this defined: Pulse_value ?

Program does not compile, which explains why it doesn't work. If you really get output then it isn't from that program.

Steve

you are not performing 4 measurements but 8 as you call pulseIn(pin, HIGH)twice in your for loop.

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