// Dec 30 2014 // The purpose of this sketch is to intercept the signal pin on the Transmitter to allow for remote switcing of // equipment. ie. trigger a lost model piezo buzzer, bomb drop, squirt gun etc on the Quad. This code reads the PWM signal length. // Requires the Signal wire + GND from the Receiver unit. Must ensure Arduino and RC grounds are tied. // The signal tester here for "GEAR" is ~104x when LOW and ~1867 when HIGH // Use this to switch an external power signal via a MOSFET or other control. // The below example is specific to triggering a buzzer when the TX signal goes above 1400. However, you can make this whatever you like. In my case, // channel 5 is triggere HIGH when the Aux switch is enabled. This turns the alarm on. The idea is that I use the remote to trigger the alarm to turn // on (as opposed to having the alarm trigger ON when the TX is turned off, or out of range). If you are looking for that functionality, y // this is a starting place, but you will have to determine what signal comes from your RX when the transmitter powers off. // Note - The LED is optional, but could help locating your model in the dark. // Note - if you are going to use an AtTiny, you will need to use Arduino-Tiny (https://code.google.com/p/arduino-tiny/) as the // default bootloader does not support Tone(). Instructions are on the link. //Uno - use for initial testing as programming/testing a Tiny is a PINTA. //int rcPin = 10; // PWM signal arduino pin //int buzzerPin = 4; //buzzer pin //ATTiny85 - pinouts are here http://highlowtech.org/wp-content/uploads/2011/10/ATtiny45-85.png //pin #1 has the black dot on the chip. // 1 8 // 2 7 // 3 6 // 4 5 int rcPin = 0; // PWM signal in from RC receiver - connect to Pin 5 (see above) int buzzerPin = 1; //Buzzer pin out to buzzer - connect to Pin 6 (see above) int ledPin = 2; //Optional - connect to Pin 6 (see above) int chPWMVal = 0; // Receiver channel pwm value - connect to a free channel on your RX. Leave value at 0. void setup() { pinMode(rcPin, INPUT); pinMode(buzzerPin, OUTPUT); pinMode(ledPin, OUTPUT); //Serial.begin(9600); //for debugging } void loop() { // Read in the length of the signal in microseconds chPWMVal = pulseIn(rcPin, HIGH, 25000); digitalWrite(ledPin, LOW); // turn the LED on (HIGH is the voltage level) //Serial.print("Channel #: "); //Serial.println(ch); if (chPWMVal > 1400) { digitalWrite(ledPin, HIGH); // turn the LED on (HIGH is the voltage level) tone(buzzerPin, 3000, 300); delay(800); digitalWrite(ledPin, LOW); // turn the LED off by making the voltage LOW delay(200); } }