Pages: [1] 2 3 ... 5   Go Down
Author Topic: Simulate push button with arduino  (Read 8221 times)
0 Members and 1 Guest are viewing this topic.
0
Offline Offline
Full Member
***
Karma: 0
Posts: 143
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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


Quote
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: http://nerdfever.com/?p=1215)

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?
Logged

Offline Offline
Sr. Member
****
Karma: 1
Posts: 486
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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.
Logged

http://dduino.blogspot.com all my Arduino/electronic projects!!!

{NEW} Getting Started, Learning, Reference + FAQ PDF!!:
[url]http://ar

United Kingdom
Offline Offline
Tesla Member
***
Karma: 227
Posts: 6637
Hofstadter's Law: It always takes longer than you expect, even when you take into account Hofstadter's Law.
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

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.
Logged

Formal verification of safety-critical software, software development, and electronic design and prototyping. See http://www.eschertech.com. Please do not ask for unpaid help via PM, use the forum.

0
Offline Offline
Full Member
***
Karma: 0
Posts: 143
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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?
Logged

Offline Offline
Sr. Member
****
Karma: 1
Posts: 486
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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
« Last Edit: January 22, 2012, 11:32:50 am by sirbow2 » Logged

http://dduino.blogspot.com all my Arduino/electronic projects!!!

{NEW} Getting Started, Learning, Reference + FAQ PDF!!:
[url]http://ar

United Kingdom
Offline Offline
Tesla Member
***
Karma: 227
Posts: 6637
Hofstadter's Law: It always takes longer than you expect, even when you take into account Hofstadter's Law.
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

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.
Logged

Formal verification of safety-critical software, software development, and electronic design and prototyping. See http://www.eschertech.com. Please do not ask for unpaid help via PM, use the forum.

Offline Offline
Sr. Member
****
Karma: 1
Posts: 486
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

hmmm ok please explain .
Logged

http://dduino.blogspot.com all my Arduino/electronic projects!!!

{NEW} Getting Started, Learning, Reference + FAQ PDF!!:
[url]http://ar

0
Offline Offline
Full Member
***
Karma: 0
Posts: 143
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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?
Logged

Massachusetts, USA
Offline Offline
Tesla Member
***
Karma: 212
Posts: 8967
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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:
Code:
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.
Logged

Send Bitcoin tips to: 1L3CTDoTgrXNA5WyF77uWqt4gUdye9mezN
Send Litecoin tips to : LVtpaq6JgJAZwvnVq3ftVeHafWkcpmuR1e

United Kingdom
Offline Offline
Tesla Member
***
Karma: 227
Posts: 6637
Hofstadter's Law: It always takes longer than you expect, even when you take into account Hofstadter's Law.
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

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?
Logged

Formal verification of safety-critical software, software development, and electronic design and prototyping. See http://www.eschertech.com. Please do not ask for unpaid help via PM, use the forum.

0
Offline Offline
Full Member
***
Karma: 0
Posts: 143
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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 ?
« Last Edit: January 22, 2012, 12:00:32 pm by Carlcox89 » Logged

United Kingdom
Offline Offline
Tesla Member
***
Karma: 227
Posts: 6637
Hofstadter's Law: It always takes longer than you expect, even when you take into account Hofstadter's Law.
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

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.
Logged

Formal verification of safety-critical software, software development, and electronic design and prototyping. See http://www.eschertech.com. Please do not ask for unpaid help via PM, use the forum.

0
Offline Offline
Full Member
***
Karma: 0
Posts: 143
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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.

Code:
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?
Code:
digitalWrite(modeButton, LOW);
pinMode(modeButton, iNPUT);
delay(3000);  // Wait 3 seconds
pinMode(modeButton, OUTPUT);
Logged

United Kingdom
Offline Offline
Tesla Member
***
Karma: 227
Posts: 6637
Hofstadter's Law: It always takes longer than you expect, even when you take into account Hofstadter's Law.
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

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.
Logged

Formal verification of safety-critical software, software development, and electronic design and prototyping. See http://www.eschertech.com. Please do not ask for unpaid help via PM, use the forum.

Offline Offline
Sr. Member
****
Karma: 1
Posts: 486
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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

http://dduino.blogspot.com all my Arduino/electronic projects!!!

{NEW} Getting Started, Learning, Reference + FAQ PDF!!:
[url]http://ar

Pages: [1] 2 3 ... 5   Go Up
Jump to: