Go Down

Topic: Non-blocking range finder (Read 543 times) previous topic - next topic

random_vamp

I'm working on a lighting project for Christmas gifts where I have a Nano driving a bunch of LEDs (via TLC5940's), and I want the patterns being generated on the LEDs to respond to people in the proximity via an ultrasonic range finder (such as http://www.arduino.cc/en/Tutorial/Ping, the one I'm using isn't a ping but has almost the same code to drive it).

The problem I'm having is that the code to use the range finder and read the result injects enough of a delay to interfere with the LED animations.  Do folks have any ideas on how to make the range finding be a non-blocking operation?

Nick Gammon

Someone recently had a non-blocking ping library. newping or something like that.
Please post technical questions on the forum, not by personal message. Thanks!

More info:
http://www.gammon.com.au/electronics

Nick Gammon

This might be it:

http://playground.arduino.cc/Code/NewPing
Please post technical questions on the forum, not by personal message. Thanks!

More info:
http://www.gammon.com.au/electronics

random_vamp

Yeah, I was just contemplating how I'd do this using interrupts and found that library: http://code.google.com/p/arduino-new-ping/wiki/Ping_Event_Timer_Sketch

The other thought I had was to add an ATTiny85 to drive the range finder and then query it as needed for current numbers via I2C or equivalent, but that would make this project more complicated than I really want to deal with.

Go Up