Arduino nano via us to PC for power
Signal via button to have high or low value to mosfet
12v in from external source (car) and negative to ground
Output I need the 12v controlled by mosfet and kill those 12v via button, I only need the positive side as the negative side is pwm x4 and 12v is constant , instead for 1 mosfet for each way I have done a bridge on the 12v (injectors) so all of them are fed by one single 12v line
Problem
I do get 12v and car runs no problem
At the moment I give signal high/low to cut the voltage to 0 it still feeds 12v and having the vcc disconnected so it should give 0v
Have common ground to car and Arduino
I can't kill the power
How do I need to wire this?
Thanks for helping
Hi yes
The code is basically if button is high
Put the mosfet low.
On vcc nothing
Gnd ground to Arduino and car
Sig to signal
Vc+ in the 12v from the car
In- nothing (have tried with gnd to car and Arduino no results)
Out+ 12v back to car
Out- nothing (have also tried with lead back to gnd to battery and no luck)
If you seriously want help, do as asked in #1.
We need a proper schematic image of your setup, and to see your actual code (posted between code tags). Without that, not possible to offer any suggestions towards solving your problem.
void setup() {
// put your setup code here, to run once:
Serial.begin(9600);
pinMode (Q, OUTPUT);
pinMode (button, INPUT_PULLUP);
}
void loop() {
// put your main code here, to run repeatedly:
int ButtonState = digitalRead(3);
Serial.println(ButtonState);
//had before "else"
if
(ButtonState == LOW)
digitalWrite (Q,LOW);
if
(ButtonState == HIGH)
digitalWrite (Q,HIGH);
}
A Nano will eventually disappear in a puff of magic smoke when powered from 12volt (in a car).
The IRF520 is not a logic level fet, so it shouldn't be used with an Arduino.
There are exceptions, where the fet is driven by an opto coupler from the 12volt source.
Post a link to the fet module you're using (not a Google page).
Everything is grounded in a car to the chassis, so loads must be switched high-side (in the + line).
An N-channel fet can't do that without added circuitry.
Normally a P-channel fet is used for that, with a small-signal NPN level converter.
Your code is incomplete.
Why use "digitalRead(3)" when you have (partially) declared a variable "button" (with internal pull up).
Now pin3 does not have pull up.
Leo..
Hi guys
Thanks for reply
The pins are 2 for the button and 3 to the signal.
Q is the button to be readed ( 0 or 1)
I have used this modules successful before with 12v battery and injectors
But here not, as I only need to control the 12+ I can't use it on the coils - as they are pwm controlled ( each of.them) that's why I am going to the - of the battery
This is the module