-
Notifications
You must be signed in to change notification settings - Fork 2
/
SpektrumBind.ino
55 lines (41 loc) · 1.57 KB
/
SpektrumBind.ino
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
/*Spektrum Binding Protocol:
Must send a specified number of falling pulses within 200ms of powering on
3 Internal DSM2 22ms
4 External DSM2 22ms
5 Internal DSM2 11ms
6 External DSM2 11ms
7 Internal DSMx 22ms
8 External DSMx 22ms
9 Internal DSMx 11ms (UNIVERSAL INTERNAL)
10 External DSMx 11ms
*/
//Pin Assignments
static const uint8_t receiverVcc = 0;
static const uint8_t switchSignal = 15;
static const uint8_t receiverSignal = 10;
static const uint8_t numBindPulses = 9; //Use Universal
void setup() {
// put your setup code here, to run once:
pinMode(switchSignal, INPUT); //Switch imput to read when reciever is powered on. Use External 10K Pulldown Resistor
pinMode(receiverVcc, OUTPUT); //Reciever Power
pinMode(receiverSignal, OUTPUT); //Reciever Signal
Serial.begin(9600);
digitalWrite(receiverVcc, HIGH); //Power On
digitalWrite(receiverSignal, HIGH); //Allows for falling pulses
delay(5000);
}
void loop() {
// Use a physical switch to power on reciever and begin pulses immediately
if (digitalRead(switchSignal)){
Serial.println("High");
delay(100); //Ensure reciever powered on before delivering pulses
for(uint8_t pulseCount = 0; pulseCount < numBindPulses; pulseCount++){ //Deliver Falling Pulses
digitalWrite(receiverSignal, LOW);
delayMicroseconds(120);
digitalWrite(receiverSignal, HIGH);
delayMicroseconds(120);
}
Serial.println("Pulses Sent");
delay(15000); //Power on transmitter in bind mode within this delay period
}
}