I have a sketch at... https://github.com/cefn/ReadingLights/blob/d6486f0508f7d6267057b8ee86f44750152859a5/lightUpLancaster/rainbowOnMovementHL1606/rainbowOnMovementHL1606.ino ...which successfully detects nearby objects and reports distances from the sensor over serial, so long as strip.begin() is commented out (as per the github version).
However, the moment strip.begin() is uncommented, and the interrupt- and SPI- logic of the Adafruit library is allowed to run, then the sensor always reports 0 distance and pulseIn never detects the sensor pulse, even when objects are placed directly in front of the distance sensor.
I'm using Adafruit's HL1606PWM library for full color control of a strip of 32 LEDs, which works well. I'm also using a HC-SR04 ultrasonic sensor to detect movement using pulseIn, and this works well. However, combining them in a sketch seems to be very bad news, even if the LEDs are off, and therefore drawing minimal power, so I'm assuming it's a software issue and really need to work out how to get them to play nicely. I gave up using NewPing because it depended on interrupts and could conflict through shared use of the same Timer but using pulseIn to detect the ultrasonic sensor shouldn't have this dependency I think, so it's really blind-sided me with very little time left to go before an installation.
Because of the nature of the project, it's not needed to run both the ultrasonic and the LEDs at the same time, so if I need to deactivate one in order to run the other, that's fine, but currently if the LED strip is ever activated, the pulseIn invocation then always returns 0 from the echo pin of the ultrasonic sensor for the lifetime of the sketch.
The sensor fails to detect even if I bracket the pulsein(...) invocation with noInterrupts() then interrupts(), which I think should prevent the strip library from taking over the processor in the middle of a pulseIn. The sensor fails to detect even if I remove the maxDuration value which determines the maximum wait time from pulseIn.
Can anyone suggest a software issue which would mean that pulsein stops working correctly when using the (Timer2 interrupt-based) HL1606 library (which you can see at https://github.com/adafruit/HL1606-LED-Strip-PWM ). Are there sensible workarounds in rewiring or reprogramming to be able to have them both attached and functioning (even at different times)?