1

I want to turn on 2 bulbs using 2 MOSFETs. The problem is that they both turn on when it should turn up just one light.

Code:

void setup() {
  pinMode(13, OUTPUT);
  pinMode(7, OUTPUT);
}

void loop() {
  digitalWrite(13,1);  
  digitalWrite(13,0);
}

See circuit below:

enter image description here

dda
  • 1,588
  • 1
  • 12
  • 17

3 Answers3

3

Try adding a delay into your loop. In your code pin 13 will toggle very rapidly, much too fast to see it. For example:

void loop() {
  digitalWrite(13,HIGH);  
  delay (1000);
  digitalWrite(13,LOW);
  delay (1000);
}

It doesn't look wired correctly. For an N-channel MOSFET the Source should go to ground, like this:

Low-side driver

Nick Gammon
  • 38,184
  • 13
  • 65
  • 124
0

The following circuit diagram works perfectly.

Mosfet circuit

sa_leinad
  • 3,188
  • 1
  • 22
  • 51
-1

i prefer you to use relay to control any ac appliance with arduino it very much safe...enter image description here

Just follow this circuit diagram and use 5v relay in your project it will always work fine.....

Shyam Singla
  • 134
  • 2
  • I fail to see how this can help. OP is not attempting to control an A.C. appliance, the diagram clearly shows that they are D.C. Also, the OP has no button in their circuit, so that is completely superfluous. – Greenonline Jul 18 '18 at 13:30