1

Hi I am using an Arduino Mega 2560 with two sparkfun zx gesture sensors, two servos, 4 rgb leds strips and 4 light switches.

With the sensor, the code relies on interrupts, which interfere with the bahaviour of the servo and leds.

My knowledge of coding is limited so I am unsure of how to work around this, I think I have to introduce some new code. interrupts leds and servos However, I am unsure of how to introduce it.

Any help would be appreciated.

1

Driving servos and LEDs from a hardware PWM may help. They will maintain a steady state even if there are interrupts. They may be a little less responsive to changes if there are interrupts.

Are you doing too much when the sensor interrupts? Typically a sensor makes multiple measurements and may be filters the results. When it is ready it interrupts. In the interrupt it should do as little as possible. Typically sending a message via global to a polling function that is not running in an interrupt. For example it may set a flag and the poling function reads the result. Reading the result in the interrupt would be bad.

0

With the sensor, the code relies on interrupts, which interfere with the bahaviour of the servo and leds.

The best solution for this problem would be to use objects and the millis() function.

Here is a great tutorial about objects and why do we use them with the millis() function. I wont explain it because it it too long and this tutorial is simply better.

I would also suggest to see the blinkWithOutDelay example code from the Arduino IDE. It is probably the first step you have to take to learn how to use the millis() function.

  • canadiancyborg, that might not be relevant – the question appears to be about conflicting use of interrupts. – James Waldby - jwpat7 Oct 31 '16 at 1:28

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy