I Just found a quick way to hook up APM2.5 to take photos using transistors .
What we need
2 x npn transistors
2 x 10K resistors (Rc)
2 x 6.8K resistors (Rb) ( this was sufficient for me to saturate the transistor )
And a small pcb and some wires .
I had a nikon coolpix lying around so I opened it up to access the switches.Carefully remove the
upper cover which covers the switches within .You can just google how you can open it (Be carefull about
the Capacitor which is used by flash , you may get a sting if u touch its leads ).
Find the switch which is just below the trigger of your camera . Check its leads (normally its a
small push switch ) . Check which of its terminals are connected to the ground using a multimeter .
And do check the voltages on the other leads when powered on ( They are normally pulled up and may show you
voltage little less than battery ) .Normally there will be 2 such leads which are not grounded and other two grounded.Connect wires ( blue and purple ) to the 2 leads which are not grounded.One will be for focusing and the other one for clicking . Connect 2 wires to battery +ve and -ve terminal (Red and Brown ) .
So just to check whether all is going well and connections are made proper . You can try connecting one
of these wire to battery ground . If nothing happens try grounding other wire . One of them will
let you focus the camera ( you can see it on lcd ). Just when u get the green square on lcd connect the
other wire to ground while still holding the previous wire grounded . If all connections are proper
,the camera should take a picture.
Now we will have to achieve this with a digital signal from APM .For which we are using transistors as switches to
connect those wires to ground .
Just check the circuit diagram( very simple ).
In the above image the wires i hold go to APM ( brown - gnd ; red (AN2) and yellow(AN3) focus and trigger pins ) .
While soldering make sure you connect both the grounds together the APMs and camera battery's .
Now for the code ( I have attached it with this post ). I took a simple bypass . I used ch6 input to trigger camera overriding the normal ch6 function .So if you plan to use my code you better be sure you are not using ch6 input .You
can see it in mission planner config screen . Just make sure ch6 function is set to none .
The code that i have added is in the CONTROL MODES tab in function read_trim_switch ( 10 Hz)
/* This part is to trigger camera transistor pins */
static bool trigger_flag_my = false; //flag to keep track once the ch6 switch is pressed
static char trigger_count_my = 0; // to count the number of times it comes to the function to keep track of time . each count represents 0.1 sec .
if( trigger_flag_my ) // if triggered
{
digitalWrite(AN2, HIGH); // focus pin
trigger_count_my++;
if( trigger_count_my > 10 ) // wait till its 1sec
{
digitalWrite(AN3, HIGH); // capture pin
}
if( trigger_count_my > 12 ) // wait till capture input taken
{
trigger_count_my= 0 ; //Reset all variables
trigger_flag_my = false ;
digitalWrite(AN2, LOW);
digitalWrite(AN3, LOW);
}
}
else
{
digitalWrite(AN2, LOW);
digitalWrite(AN3, LOW);
if( g.rc_6.radio_in > 1500 )
{
trigger_flag_my = true ;
trigger_count_my = 0 ;
}
else
trigger_flag_my = false;
}
/// END OF CAMERA TRIGGER
Add this at the start of the function .
And add this to initialise the pins in SYSTEM tab in the function init_ardupilot just below led pin definitions ( just to make it easy to locate in case u want to remove it later )
// setup IO pins
pinMode(A_LED_PIN, OUTPUT); // GPS status LED
digitalWrite(A_LED_PIN, LED_OFF);
pinMode(B_LED_PIN, OUTPUT); // GPS status LED
digitalWrite(B_LED_PIN, LED_OFF);
pinMode(C_LED_PIN, OUTPUT); // GPS status LED
digitalWrite(C_LED_PIN, LED_OFF);
//---------------------------------
pinMode(AN2, OUTPUT); // Cam focus
digitalWrite(AN2, LOW);
pinMode(AN3, OUTPUT); // Cam trig
digitalWrite(AN3, LOW);
//--------------------------------
Once done with the code the last thing to do is hook the ch6 of your Tx to APM
and go to radio calibration tab and check the ch6 value . Make sure you set it up such that when u
switch the value goes above 1500 and when normal its value is less than 1500 .If not you can change
it in Transmitter setup .
Hope it works for you ! Thank you !


