Running car window motor with arduino

I have a car window motor that I want to operate with Arduino.
The button that operates the motor works like this:

When it should be stationary it gives +5 vdc
if pushed up it connects to +12v
if pushed down it connects to ground.

I was just wondering what would be a good circuit to operate this.
I tried to build a transistor + rc filter, but when measuring voltage it didn't seem to work.

I have plenty of IRL3705N mosfets and RC filter I tried I used 10k ohm + 0.1uF ceramic.

the idea of the project is to operate windows, mirrors and backing up camera via touchscreen connected to an arduino.

of course the original switch probably doesn't use RC filter, since it is analog (Including those in your links).

To work around having wire up all the end switches and logics, I wanted to just replace the switch, that operates like I said. It has either +5v, +12v or 0v.
SO I was thinking that I would run the +5v by running pwm at around 40% duty cycle combined with RC filter to smooth it out.

But maybe my approach is wrong all together.
Maybe I should just run +5v to it and then use either relay or something to pull it eiher ground or +12v.

How many wires go to the motor itself? Do you know if there are any microswitches for detecting end-of-travel or is the motor current monitored to detect stall?

From the switch there is only one wire going to the motor, which is signal I assume. The motor itself has ground, +12v, switch and parking lights.

I'd advise you to get wiring diagram for your car!. If you can't find it online look for a service manual.

When it should be stationary it gives +5 vdc
if pushed up it connects to +12v
if pushed down it connects to ground.

That's very odd! Is that a SPDT switch? A DPDT switch? The "5V" may not be "real". Something might be floating.

If it's not a simple DPDT center-off switch, there is probably a relay (or two) somewhere. A MOSFET would be unlikely.

I was just wondering what would be a good circuit to operate this.
I tried to build a transistor + rc filter, but when measuring voltage it didn't seem to work.

We don't know anything about yoru circuit... We don't know anything about the current (Amps or milliamps). A voltage divider (2 resistors) or PWM into an RC filter can get you 5V from 12, but only at very-low current.

You can always replace a switch with a relay (or multiple relays) because a relay is an electrically-operated, electrically-isolated, switch. But, you have to be careful adding a relay because if the existing switch and added relay conflict you can get a short an burn-out a fuse (or something worse than a fuse).

P.S.
Another approach is to disconnect all of the existing wiring and start-over. You can look-up how to reverse a motor with a DPDT switch/relay. (It's super-easy.) You might want to buy a little cheapo 12V motor to experiment with "on the bench".

You can get center-off switches but relays only have two states so you need a 2nd relay for on/off. And, you can wire a center-off switch to two Arduino inputs to read all 3 switch-states if you want to keep the existing switch or use something similar.

Everyone is so hung up on motor part of this thing, while I am looking at the switch.

I did some experimenting, and the switch connects the +12v or ground to the pin that goes to the motor. The parking light wire powers the led inside the switch.

So the motor gives the floating +5v to the wire and switch either pulls it to the +12v or ground, thus giving it the direction and the logics inside "motor" handles all the hard work and thinking.

So I can do this with 2 relays. one connects it to +12v and the other connects it to ground as long as user presses the button.

tuomasjar:
Everyone is so hung up on motor part of this thing, while I am looking at the switch.

I did some experimenting, and the switch connects the +12v or ground to the pin that goes to the motor. The parking light wire powers the led inside the switch.

So the motor gives the floating +5v to the wire and switch either pulls it to the +12v or ground, thus giving it the direction and the logics inside "motor" handles all the hard work and thinking.

So I can do this with 2 relays. one connects it to +12v and the other connects it to ground as long as user presses the button.

Did your experimenting include actually trying what you have discovered? Does it work the way you describe it?

Paul

tuomasjar:
From the switch there is only one wire going to the motor, which is signal I assume. The motor itself has ground, +12v, switch and parking lights.

I meant wires to the motor, not to the winder unit as a whole.

Paul_KD7HB:
Did your experimenting include actually trying what you have discovered? Does it work the way you describe it?

Paul

Yes it did work as I assumed. I used 2 relays controlled by arduino. other one is connected to ground and other one is connected to +12vdc. The signal wire from motor control is connected to normally open of both relays. When winding up activate the relay with +12vdc and when winding down activate relay with ground. of course one should make sure not to activate both at the same time.