Skip to main content

Timeline for pulseIn() function not working

Current License: CC BY-SA 3.0

6 events
when toggle format what by license comment
Jun 8, 2018 at 23:34 comment added Kirby It works strange anyway. It works for 10s and doesn't for 1s. It's always returning zero... pulseIn(buttonPin, HIGH, 1000000UL); - 1s.
Jan 7, 2017 at 10:13 comment added jfpoilpret The timeout is global this means in these 10 seconds, the signal must first go HIGH then go LOW. If you call pulseIn() at t0, and the signal gets HIGH at t1, then gets back LOW at t2, then you must have t2 - t0 < timeout (10s), then pulseIn() will return t2 - t1; if ever t2 - t0 > timeout, then the pulse will not be recognized and pulseIn() will return 0.
Jan 7, 2017 at 10:09 comment added Hasan And as you say, value = pulseIn(pulsein, HIGH,10000000UL ) that mean pulseIn() function wait for 10 seconds until signal goes LOW or gets that 10 second long pulse. I can't understand. Can it possible to get 10 seconds or any seconds pulse means length of pulse is 10 seconds or any seconds length with help if this line of code.
Jan 7, 2017 at 10:08 comment added Hasan Thank you for explanation. Here, i used delay(1000) because every time whenever readings are serially printed in serial monitor, it's very hard to identify the changes between those readings. So, delay(1000) used only for my convenient purpose, so i can see every readings after every 1 second,nothing else.
Jan 7, 2017 at 9:53 vote accept Hasan
Jan 7, 2017 at 9:45 history answered jfpoilpret CC BY-SA 3.0