Simulate push button with arduino

Hi,
i have a 808 keychain camera that i want to hack in order to record my motorcycle trips.
This is the camera:

The right side of the capacitor near the left end of the board. This can be used to monitor whether the camera is turned on. When there is 3.3v on this cap, the camera is turned on. When there’s 0v (ground), it’s off. Connect this to an input line on your microcontroller.
The lower right connection on the power button. This controls when the power button is pressed; connect it to an output. Driving this pad low (0v) presses the power button, driving it to 3.3v releases it.
The upper right connection on the mode button. This controls when the mode button is pressed. The voltages on it are the opposite of the power button: 3.3v presses the button, 0v releases it.
Note there’s a place at the top right of the board for another SMD LED. I soldered a green one there to see what it would do – it lights up when the board is connected to a live USB port.
Last, you’ll need a ground connection. I found the best place to be any one of the four tabs that attach the USB connector (on the other side of the board, not shown). Just add a blob of solder and attach the ground wire.

(Source: Driving the “808” keychain camera with a microcontroller « Nerd Fever)

The guy says that connecting the lower right of the power button to an output pin (microcontroller), then doing
digitalWrite(Power_PIN, LOW); -> is pressing the power button
digitalWrite(Power_PIN, HIGH); -> is releasing the power button

Right ?

However i am confused, because i cant understand if he's using the same power source to power the camera and the microcontroller, can someone explain this to me ?
What i want is to power the camera with it's internal battery and power the arduino with a different power source.
Wouldn't it be better just to use two opto-isolators to control the push buttons?
What about the power status? Can i connect it directly to an input pin on arduino?

you could power the camera with its own battery, then share the GND between the arduino and the camera. then you need a power source for the arduino too.

then find which side of the switch is +3.3v and which side is 0v(when not pressed); connect a digital pin to the 0v side so that when you bring the pin high in code, it activates the button. you will need to set your AREF pin on your arduino to 3.3v so that you don't fry the camera with 5v. the arduino has a built in 3.3v regulator so just run a ire from the 3.3v pin to the AREF pin.

I suggest you use either two opto isolators, or two small signal NPN transistors, or two 2N7000 mosfets to simulate pressing the buttons. If you want to monitor the power status, then it is easiest to use a common ground anyway, in which case there isn't much point using opto isolators.

sirbow2:
you could power the camera with its own battery, then share the GND between the arduino and the camera. then you need a power source for the arduino too.

then find which side of the switch is +3.3v and which side is 0v(when not pressed); connect a digital pin to the 0v side so that when you bring the pin high in code, it activates the button. you will need to set your AREF pin on your arduino to 3.3v so that you don't fry the camera with 5v. the arduino has a built in 3.3v regulator so just run a ire from the 3.3v pin to the AREF pin.

So, this way i dont need opto-isolators and still can use two power sources, right?
Also, i wire from 3.3v to AREF pin and dont need to set this in code also?

  1. yes
  2. yes

i was going to say just run the keyfob off of the arduino 3.3v pin... but 50ma is the max for the 3.3vreg. "160 mA when recording a video." so i guess you cant

Carlcox89:
So, this way i dont need opto-isolators and still can use two power sources, right?
Also, i wire from 3.3v to AREF pin and dont need to set this in code also?

sirbow2 is suggesting you connect an Arduino digital output direct to your camera board. DON'T DO THAT, you will fry the board. or the microcontroller in the Arduino. Changing Aref doesn't affect the voltage on digital output pins. That is why you need to use transistors or mosfets to simulate the switches.

hmmm ok please explain .

Ok dc42, now i think i understand how it works.
So, for the two switches(push buttons) i should use two opto-couplers and share the ground (arduino GND and camera GND).
For camera power status, how can i connect it to arduino so i can know if camera is on/off?

sirbow2:
you will need to set your AREF pin on your arduino to 3.3v so that you don't fry the camera with 5v. the arduino has a built in 3.3v regulator so just run a ire from the 3.3v pin to the AREF pin.

The Aref (Analog Reference) pin only sets the reference voltage for the A/D conversion (analogRead()) and only when the reference is set to EXTERNAL. Until you set the reference to EXTERNAL the 3.3V line will be shorted to the 5V line!

The Aref pin DOES NOT SET THE OUTPUT VOLTAGE FOR DIGITAL PINS!

To activate the button you pull it to ground. To de-activate it you let it float. You can do this with:

digitalWrite(powerButton, LOW);
pinMode(powerButton, OUTPUT);  // Pull the signal low to activate the power button
delay(500);  // Wait half a second
pinMode(powerButton, INPUT);  // Release the power button.

Since you are not using an output pin set to HIGH you don't have to worry about the Arduino output voltage.

OK, here goes. If you run the Arduino form 5v then the digital outputs always swing between 0v and +5v. The only thing the Aref pin does is set the voltage reference for the on-chip ADC.

In fact there is a way you can connect an Arduino digital output directly to the pushbutton, assuming that in the cameas the pushbutton shorts the signal to ground and a pullup brings it up to +3.3v when the button is not pressed. The technique is to always have LOW written to the pin register, then set the pin to Output to simulate closing the pushbutton and set it to Input the rest of the time. However, it only takes a software slip-up that writes HIGH to the pin and the result will be +5v fed to the camera.

[EDIT: that is the same solution that johnwasser gives in his reply.]

Another possibility is to use a diode wired with cathode to Arduino output pin and anode to the pushbutton. Then the Arduino can only pull the camera input down to near 0v and can't feed +5v into it. Again, this assumes that the pushbutton is wired to ground.

Does that help?

Ok, so i can connect directly the pad of the switch to arduino using the method you both described.
What about the other question, about getting the power status of the camera ?

You don't need opto isolators, and you can connect those pads either directly to Arduino pins or via a small signal diode such as 1N4148. As you are a novice, I recommend using the diode for safety. See my earlier email.

To read the power status, I suggest you connect the power status pad of the camera through a 10K resistor to an Arduino analog input pin. I'm suggesting using an analog pin so that it will still work even with the camera battery a bit below 3v. The 10k resistor provides protection when the camera is on and the Arduino is off or vice versa.

Ok, so for the power button it'll work like John said

To take a movie on the #3 camera (others may vary), press the power button for 1.3 seconds to turn on the camera. Then release it and wait 4.5 seconds. Then press the mode button for 3.0 seconds. The camera will start recording a movie.

digitalWrite(powerButton, LOW);
pinMode(powerButton, OUTPUT);  // Pull the signal low to activate the power button
delay(1300);  // Wait 1.3 seconds
pinMode(powerButton, INPUT);  // Release the power button.

but for mode button, since it works differently (0v OPEN, 3.3 CLOSED)

would this work?

digitalWrite(modeButton, LOW);
pinMode(modeButton, iNPUT);
delay(3000);  // Wait 3 seconds
pinMode(modeButton, OUTPUT);

I think you may need to be careful here, if the mode button is 0v open and 3.3v closed then it suggests that the button may be wired to +3.3v with a pulldown resistor from the pad to ground. If that's the case then using a p-channel mosfet or pnp transistor is a good solution.

I suggest you measure with a multimeter the voltage on the other side of each button when the camera is turned on.

oh ok this makes sense, i was thinking the button was going to +3.3v when pressed, not GND

Some Arduinos run at 3.3V so if you need to send a few mA to to your camera at 3.3V that would be easy if you are using an Arduino at the right Voltage.

Alternatively, as long as the amount of current you're providing is tiny, you could use a resister pair to divide 5V at the pin down to 3.3V at the camera.

The spec you quoted talks about a need to drive the pin low and then drive it high again. That seems odd to me. I'd expect to find that the line was pulled high (or low) via a resister and then pulled low (or high) via the switch when the switch was closed. In that case I'd expect you would need to pull the signal low to simulate closing the switch, and then let it float high again to simulate opening it. In that case you don't need to provide 3.3V - just pull it to earth as dc42 already suggested.

See attached (excuse the scrappy diagram) for how I would simulate a button press depending on whether the button is connected to +3v (with pulldown to ground) or to ground (with pullup to +3v). I'm assuming 3v not 3.3v because I presume the camera is powered from a lithium battery.

I'll try measure the pads of both push buttons, then i'll post the values.
what I need to get (when camera is on) is what voltage is running at powerButton and at modeButton (without actually pressing them), correct?

EDIT: the camera afaik is powered from 3.7v battery.

OK, 3.7v nominal then, but the circuitry is the same. You can probably get away with using a digital input to read the power status instead of an analog input, because with a 5v supply to the Arduino, anything from 3.0v upwards on a digital input pin is guaranteed to be recognised as a logic high.

Ok, assuming i got it correctly.
Is this right?

(sorry for crappy pic)