Hello,
I am using an Arduino Due to stabilize a quadcopter.
The Due is working/communicating with an IMU, a ping sensor, 4 motor drivers by I2C, etc.
Timing is quite important, rigth now my loop() takes around 20ms, and I'd like to lower it.
So I found out that just calling the ping sensor and waiting the response wave can take up to 6ms, because that's the time the wave takes to travel from the sensor to the ground and come back.
Then I thought: "I can use the Scheduler library to make another task where the ping can be measuring in its own loop..." so I don't lose those 6 ms.
My 2 questions are:- Should I use the scheduler library or is there an easier way to accomplish this?
- In case I use the Scheduler library... can I safely use in the main loop a variable that the ping loop is changing?? (first, is it even possible???) Wouldn't I need a semaphore?
Thank you very much!
