Pages: [1]   Go Down
Author Topic: Non-blocking range finder  (Read 490 times)
0 Members and 1 Guest are viewing this topic.
Offline Offline
Jr. Member
**
Karma: 0
Posts: 51
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

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?
Logged

Global Moderator
Offline Offline
Brattain Member
*****
Karma: 474
Posts: 18696
Lua rocks!
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Someone recently had a non-blocking ping library. newping or something like that.
Logged

Global Moderator
Offline Offline
Brattain Member
*****
Karma: 474
Posts: 18696
Lua rocks!
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

This might be it:

http://playground.arduino.cc/Code/NewPing
Logged

Offline Offline
Jr. Member
**
Karma: 0
Posts: 51
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

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.
Logged

Pages: [1]   Go Up
Jump to: