1

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
  • IRLib.cpp seems to me to be the bulk of it. – Nick Gammon Oct 6 '16 at 20:32
  • 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
  • I tried but storing them in an array is also slow. @EdgarBonet – DarkHorse Oct 7 '16 at 16:45

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.