I am currently working on a project which requires me to record IR signals. (I realize there is a library available for doing this but I want to learn how to do this myself).

I tried using a simple sketch which prints out pulseIn() times on the Arduino, but then if I try to record them into an array, the Arduino misses the pulses happening while it is writing the timings to the array.

How can I achieve being able to record these fast pulses to the Arduino's memory without skipping some of the pulses?

  • I wouldn't use pulseIn myself because it can block for quite a while until it times out. You could use interrupts or other methods. Try reading the code for IRLib and see the techniques they use. – Nick Gammon Oct 6 '16 at 20:19
  • @NickGammon I am unsure of which file in the library records the code. – DarkHorse Oct 6 '16 at 20:21
  • 1
    You could record the pulses first, and print them later. Storing the pulses in the array should be significantly faster than printing them. – Edgar Bonet Oct 7 '16 at 8:55
  • 1
    I tried but storing them in an array is also slow. @EdgarBonet – DarkHorse Oct 7 '16 at 16:45
  • 1
    That's really weird. Can you show the code? I'd like to take a look at the generated assembly. – Edgar Bonet Oct 7 '16 at 16:57

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.