Does this look OK to simulate a button press?

Hi,

I've been tinkering with the Arduino for a couple weeks now and based on what I've read and learned I feel this will work.
I would just like for someone to triple check my work so I don't blow up my house.

I'm trying to use my arduino to control a 4 level dimmer. This dimmer uses mommentary push buttons. When you press the button it shorts 12v to gnd and the light turns on to the desired setting.

My biggest question.
Am I using the MOSFET correctly for this application?

The code to simply turn it on and off

void setup() {
  digitalWrite(dimfull, HIGH);   // +5v to MOSFET gate
  delay(250);               // 
  digitalWrite(dimfull, LOW);    // 0v to MOSFET gate
delay(3000)
  digitalWrite(dimoff, HIGH);   // +5v to MOSFET gate
  delay(250);               // 
  digitalWrite(dimoff, LOW);    // 0v to MOSFET gate

This is how I plan on wiring it. I'll have this exact same wiring to the off button too.

Thanks for any help,

-ruli00

No that is totally wrong.

Well I'm glad I didn't test it lol. Anyone have any suggestions of where I should restart?

Thanks

-ruli00

any suggestions of where I should restart?

Well I would have a better idea if I knew what this "dimmer" was and what you wanted to do with it.

Is this 12V isolated from the mains? The answer to that will determine the approach you take.
Are you trying to make something that detects this pulse or that produces this pulse or both?

Do you know what current flows through the push switch when it is pushed and do you know what voltage is across this switch when it is not pushed?

I'm using this dimmer Leviton R52-6161-00W White Commercial Grade Four Level Step Decora Dimmer - Newegg.com-pla--Fan+%26+Dimmer+Switches-_-N82E16803000884&ef_id=U4Hz9wAAAJJHh0v0:20140528130732:s

My end goal is to make this dimmer smart and control it from a Ninja Block. If I can learn to properly simulate a button press then I should be able to convert many of the items in my home to be controlled remotely for relatively cheap.

The push button on the dimmer reads 12v at one leg and GND at the other. If I bridge those to point together with a piece of wire then the light turns on. Yes the 12v appears to be isolated.

Thanks for the help Mike

-ruli00

Yes the 12v appears to be isolated.

I am not convinced of that after looking at that link.
You better use an opto isolator.
Schematic attached

opto.png

Let me start by saying I am in no way an expert, I am just scratching the surface myself. I did however recently complete a large project using MOSFETs. If I understand what your trying to do I would approach in this way...

Remove the pushbutton completely (the MOSFET is taking its place). Connect the input wire from the removed pushbutton to the source pin of your MOSFET, the output wire from your removed pushbutton to the drain pin, and the gate pin to a digital output on your arduino. I'm sure you may need some resistor or diode in there to but don't know much more then that.

The Arduino projects from the starter kit indirectly cover what your trying to do. Projects 2, 9, 15 will certainly put you in the right direction.

@twelch
If there is not complete isolation from the mains your method is dangerous.

Mike, what would be considered the mains in my case?
I would to be able to use MOSFETS because of the low cost but safety is my main concern.

-ruli00

I agree with what others have said... What you are trying to do is potentially very hazardous. You absolutely need an optoisolator. Also, you said you saw 12v on a voltmeter. Was that 12v DC or was that 12v AC? It can make a difference!

Its 12v dc

Well Mike as I said, I am not an expert. Simply offering what little I have in hopes of helping others the way I have been helped.
I am guessing when you say "complete isolation from the mains" that means the power from the device and the power from the Arduino would be separated from each other, which is why I said "I'm sure you may need some resistor or diode in there to but don't know much more then that". I also recommended taking a look at the Starter Kit projects, Project 15 does exactly what ruli00 is describing using an optocoupler instead of a MOSFET. Project 9 uses a MOSFET to control a load greater then what the Arduino can handle on its own and uses a diode to protect the board.

When it comes to matters of safety involving high voltages like the AC power line, it is better not to offer answers if you are not highly knowledgeable.

Its 12v dc

I never offered an answer, I said this is how I would approach and I'll say it one more time for the geniuses in the room, I very clearly stated "I am not an expert"

and truthfully if your the type of person who thinks only an expert can help, that a beginner should stay quite because his ideas are useless, then I feel bad for you because no matter how smart you are you will never reach your full potential. No matter where I am, what I am doing, or who I am doing it with I know that there is always something to learn from everybody you encounter.

twelch:
No matter where I am, what I am doing, or who I am doing it with I know that there is always something to learn from everybody you encounter.

amen to that, @twelch.

likewise, one not need to put his hand into a bear trap to understand the consequences; merely watching someone do it is enough for most people. So, seeing comments (experienced or otherwise) is great for learning, it inspires more comments.

I get a lot from folks contributing to these forums at all levels. I read 100's of posts for every question I ask, I take so much more from this forum than I contribute.

But on that vane, I've added nothing to the OP's question... so I'm off.

twelch:
Well Mike as I said, I am not an expert. Simply offering what little I have in hopes of helping others the way I have been helped.
I am guessing when you say "complete isolation from the mains" that means the power from the device and the power from the Arduino would be separated from each other, which is why I said "I'm sure you may need some resistor or diode in there to but don't know much more then that". I also recommended taking a look at the Starter Kit projects, Project 15 does exactly what ruli00 is describing using an optocoupler instead of a MOSFET. Project 9 uses a MOSFET to control a load greater then what the Arduino can handle on its own and uses a diode to protect the board.

Where are these projects located. I'd like to see them for reference.

Like I said, I want to play this safe and want do what is right not what will just work.

Thanks,

-ruli00

Do I need a 4 pin optoisolator or can I use a 6 pin? The 6 pin one are a lot cheaper and I'm going to need a ton of these.

Thanks

It should not matter, but post the type you are thinking of.

In the Arduino IDE the sketches are located under File>Examples>Starter Kit, Some of the projects are located somewhere one the Arduino.cc site. I am looking for it now...

***I apoligize, I was under the impression ALL of the projects were up on the site, but only some are. I just checked into the copyrite however and it is okay for me to share as long as I don't claim it as my own or claim to be endorsed by anyone. PM me an e-mail address and I will send you the images for #15

and truthfully if your the type of person who thinks only an expert can help

You know nothing about me. What I do know about you, is that you gave potentially very dangerous advice to someone.

And that is not what I said.