by zachtos » Sat May 23, 2009 9:36 am
Correct, it works fine if I pause wave files while sending IR data and waiting for IR data. The problem is that the device is pretty much constantly waiting for IR data (it only sends out IR data about 60ms pulses x 4-5 times / second). But it reads pulseIn() for pretty much the entire duration outside of that (so you can take hits inbetween gun shots).... SOOooo, my gun sounds are basically being paused constantly. If the wave could play and not destroy pulseIn() reads, then this would work perfectly. Unless there is something I do not understand about pulseIn() or how the waveshield disrupts timing???
I am calling pulseIn(sensorPin, LOW, 150) // 150ms gives the sensor enough timeout time so it doesnt timeout while waiting for a data transmission, it seems to miss many shots if I go lower on the time out....
Also, I am sending the IR pulse 3 X per shot because they never seem to register only 20% of the time if I just send the pulse once, but if I loop it 3 times every button push, it works great. (IE, you dont want to be a sniper and have your shots only hit 20% of the time, but it's less noticibale if you are a fully auto gun)...
I can not get waves to resume smoothly either when exiting the pulseIn() function, they seem to *click* as soon as it resumes, which ruins the sound effect.
Perhaps all these timing critical things are just not compatible w/ a waveshield? I thought about calling pulseIn() as an interupt, but I could not get it to work properly, and I think the waveshield used all the interupt ports (pin 2,3)...
Maybe I should just use integrated sound chips where I send a few bits high on the D/I outs to call a wave play, that would not affect sounds at all, but I would not be able to resume file playbacks? or have any idea where to start looking for a ISD chip or pre-built circuit if there are cheap ones available?