The flags are then used by the remaining functions to extract and process the data collected by the ISRs.Flags are set in each ISR to indicate when new pulses have been received.The time intervals between pin changes are used to calculate pulse width, and repetition period.The time of the interrupt is noted via the use of micros() before returning back to the main loop(). Within each ISR a FOR loop and IF statements are used to determine which pin has changed, and which RC channel it belongs to.A voltage change on any of the selected pins will trigger one of three Interrupt Service Routes (ISR) depending on which port register the pin belongs to ISR(PCINT0_vect) -> Port B, ISR(PCINT1_vect) -> Port C or ISR(PCINT2_vect) -> Port D.A setup function enables pin change interrupts by setting the appropriate registers for each pin listed in the pin array.The input pins are identified in an array.
Note: this code will not work with the software serial or any other library which uses pin change interrupts.įor those interested in how the code works: As such the example code shown in the "how to use" section can just be used as a means to an end. The primary aim of this project was to create a generic RC receiver with fail-safe "module" that can be quickly moved between projects. This makes the code easy to use even for beginners. The functions used automate the set-up of the interrupts and the extraction of data from any digital or analog pin (excluding A6 and A7), on the Arduino Uno, Nano or Pro Mini. This code measures PWM (Pulse Width Modulation) signals using pin change interrupts.
Have your RC model respond to a loss of signal or low battery voltage.
flight stabilization/ autopilot, heading hold, altitude/depth hold, auto-leveler, sense and avoid, return home.) Apply servo mixing, switch lights on/off, control pumps/valves, set bespoke sequences.You will only be limited by your imagination: You should also have a working knowledge of:Įxample uses of Arduino in RC models / robots Servo City Explanation of PWM control of Servos