Go Down

Topic: How can i measure 0.5 micro second pulse width with pulse in function (Read 319 times) previous topic - next topic

rahulkp1986

Hello all
I need to measure a pulse width up to .5 micro second resolution im using the below code

Code: [Select]
int pin = 7;
unsigned long duration;

void setup() {
  Serial.begin(9600);
  pinMode(pin, INPUT);
}

void loop() {
  duration = pulseIn(pin, HIGH);
  Serial.println(duration);
}
See also


I tried using arduino uno, STM32F103C8T6, and Lolin NodeMCU ESP8266 CP2102  all are giving resolution of 1 micro second, and there is an error of +- 2 micro second

i have heard STM32F103C8T6, and Lolin NodeMCU ESP8266 CP2102 are faster than uno.. so it should give much higher accuracy right? but in my case all are same

can anyone help?

AWOL



Go Up