Last week, I made a Dizzy Woodpecker using IR distance sensor and a servo motor. Since in class last week we learned about tone, I wanted to add music and LED to the circuit. So, this time I made a Hiding Spooky. Here’s what I had in mind.
I wanted to show & hide Spooky using force sensor and a servo motor, so when it’s touched, Spooky will move and can be seen. And since it’s near Halloween, I’d add Halloween Theme music and a blinking RGB LED.
I used an analog input to the force sensor and digital output to servo motor, RGB LED, and speaker. Here’s my circuit.
But when I ran the program, something weird happened. Then I realized that Arduino can’t run various functions simultaneously in a loop function. I was frustrated by it, I couldn’t find an answer that said Arduino could run more than one function at the same time. Unless you have more than one Arduino.
It makes sense though. Because in the loop function, the program calls a function one at the time. But, I’m still wondering is there any way to run at least two functions at the same time? Somebody on the internet said that we should try to manipulate the delays. But still, I don’t understand it. How can I manipulate the delays if the loop function call every function in sequence.
So, I ended up giving up. I’m still questioning about it. Here’s my Hiding Spooky. In the first video, I only ran the servo motor with force sensor.
The second video shows how Arduino can’t run functions simultaneously (or that’s what I understood until I wrote this blog).