APM:Copter参考手册目录3.1.6-Using the Relay Switch
APM:Copter参考手册目录3.1.6-Using the Relay Switch
You can use the onboard relay switch of APM 1 to control on/off devices that consumer more current than can be supplied by simply turning a digital pin on and off.
The way the relay works is that it switches between connecting a common center pin to one of the two outer pins (State 1 or State 2). So if, for example, you wanted to trigger a solonoid, you’d connect the solonoid’s V+ pin to the center pin, and connect State 1 to APM’s V+ and State 2 to Ground. In State 1, the solonoid would go on; in State 2 it would go off.
You script it into missions with any GCS. Here are the commands in the Mission Planner:
Here’s some code that demonstrates it switching from one position to another.
pinMode(RELAY_PIN,OUTPUT); while(1) delay(3000); Serial.println("Relay Position A"); PORTL |= B00000100; delay(3000); Serial.println("Relay Position B"); PORTL ^= B00000100;