Go Down

Topic: Simulate push button with arduino (Read 8936 times) previous topic - next topic

Carlcox89

#30
Feb 01, 2012, 12:25 am Last Edit: Feb 01, 2012, 12:45 am by Carlcox89 Reason: 1
they are split horizontally like i said before, so talking about the power button:
the bottom legs are 0v when camera is on and when i press the button, it goes to 3.3v
This is how they are split


so to drive this pushbutton through a pnp transistor,
is it simple as just driving it HIGH for pressing (closing switch) and LOW for open switch?

About the mode button, since the top legs are 3.3v when open, and when i press the button they get 0v (i just need a 1N4148 transistor) and what code should i have for this one ?

sirbow2

#31
Feb 01, 2012, 12:48 am Last Edit: Feb 01, 2012, 01:03 am by sirbow2 Reason: 1
from teh pic you posted before(the updated multi meter readings) you need a PNP for the power button, and a diode for the mode button

like the first pic below.

if the button is 0v when pressed(mode button) use the Button to Gnd method from the second pic. if 3v when pressed(Power Button), use the button to 3v method from the second pic.

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

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

Carlcox89

Yes, correct.
But what about the code for pressing/releasing each one?
johnwasser told me that for the one that is 0v when pressed (actually mode button, that i have connected throough 1N4148) i had to do this:
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.

never setting it to HIGH...
but what about the one that i driven by the PNP ?

sirbow2

#33
Feb 01, 2012, 01:04 am Last Edit: Feb 01, 2012, 01:09 am by sirbow2 Reason: 1
yes, for the diode method, you are just changing between floating and GND:
Code: [Select]

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


for the PNP it should be just regular LOW/HIGH
http://dduino.blogspot.com all my Arduino/electronic projects!!!

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

Carlcox89

Ok i think i forgot to connect the GND of the camera to the arduino one.
let me check

Carlcox89

#35
Feb 01, 2012, 01:19 am Last Edit: Feb 01, 2012, 01:38 am by Carlcox89 Reason: 1
weird, now that i have GND of camera connected to arduino's ground, when the emitter leg is connected to the top of switch and collector (from pnp transistor) connected to bottom, camera switches on and off continuously without arduino  being on :o

dc42

What code are you using to drive the PNP transistor? The pin should be HIGH normally, and LOW to simulate pressing the button. Maybe you are holding the pin LOW?

For the mode button, you can either drive it as you already are, or since you have used a diode to connect it, you can just configure it as an output pin all the time and drive it the same way (that is, normally HIGH, but LOW to simulate pressing the button).
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.

Carlcox89

the problem is that without arduino connected (by USB), but sharing grounds the camera turns on then afterthought few seconds off.. and does that continuosly.
I have a pushbutton connected to arduino (I have tested it separately) and when I press it goes high, when its normal its low.
so I just put the same code but to drive the pnp transistor (for power button)
so when I press it'd drive high the powerbutton of camera..but since the campera is looping on/off I don't know what's wrong

dc42

OK, you need to change the circuits if you want the camera to work normally when the Arduino is powered down. Currently, when the Arduino is not powered, it will behave as if both buttons are pressed.

See attached. With this circuit, a logic HIGH on the digital pin simulates a button press. I'm suggesting using a mosfet for the low side switch, however an NPN transistor with a 10K resistor between base and pin instead of the 10K resistor between pin and ground will probably do.

The point marked A is the output of the low side switch (the one where you were using a diode before), and B is the output of the high side switch (PNP transistor as before).
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.

Carlcox89

So, the (**) is a 2N1000 transistor ?
and A connects to actual mode button (top pins), that works like 3.3v and when pressed goes to 0v, correct?

And (*) can be any NPN transistor like 1N4148?
and B is connected to actual powerbutton (bottom pins) connected to collector and top pins to emitter, so that when i set HIGH it's like pressing the button, right?

dc42


So, the (**) is a 2N1000 transistor ?


No, 2N7000.


and A connects to actual mode button (top pins), that works like 3.3v and when pressed goes to 0v, correct?

And (*) can be any NPN transistor like 1N4148?
and B is connected to actual powerbutton (bottom pins) connected to collector and top pins to emitter, so that when i set HIGH it's like pressing the button, right?


Yes, except that 1N4148 isn't a transistor, it's a diode. Any small signal NPN transistor will do.
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.

Carlcox89

Yes, my bad of course it's a diode!
Just need to go out to buy a 2N7000

dc42

If you have some small signal NPN transistors lying around, try one of those instead:

- emitter to ground
- base via 10K series resistor to Arduino pin
- collector becomes point (A) in my diagram
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.

Carlcox89

I went out to buy the 2N7000 transistor for button A but forgot to buy one for (*) connection :|

Carlcox89

Can i use a 2N2222 for the (*) connection ?

Go Up