Hi everyone - Library: ver.

Hi everyone -

Library: ver. 3.1
Arduino: 1.6.8
OS: Mac

I’ve been playing around with FastLEDs for a bit for my project, which will be an interactive installation/sculpture. What I’m attempting to do is to trigger an LED animation (in this case “confetti” from the DemoReel100 sketch) when the FSR senses any sort of pressure.

Here’s the code:

I tried to do it so there won’t be any lights when it’s not being “interacted” with (which is why the sketch has “doNothing”) but it seems to keep going back to being “confetti” no matter what. Also tried using different animations, but it looked like a mess. Went back to “confetti”, then slowed it down so there’s a contrast between the “non-interacted” version vs. the FSR-squeezed version. Video shows the point I’ve gotten to, and been stuck there for a while now…

Also, is there a way to keep the “confetti” animation going for a few more seconds after the FSR gets squeezed? So it’ll be: squeeze > let go > light animation goes on for 5 seconds > goes back to normal.

Any advice/help will be greatly appreciated. Thank you!

else (fsrReading > 20); // when pressure is greater than threshold

That line is the cause of the problem, it should be

else if (fsrReading > 20)

Two things to notice, the if is needed, and no semicolon at the end.

Thanks for the input, Russell! Now I just gotta figure out how to get the animation to loop for a bit, then go back to being “nothing” again…

Jane, anytime your interaction is triggered you can save the current time (using millis) and then make the animation run for a certain time before going back to idle state. You’ll also need a variable to save if it’s been triggered. Some sudo code:

boolean triggered = false;

Check the trigger
If it’s being triggered then
Save current millis.
And set triggered = true.

If triggered is true
Run animation
Check timer, have we run long enough yet?
Yes, then set triggered = false

Else run idle animation (ie triggered = false)