user36742: 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:


user10794: 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:


36742: <p>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.</p>

<p>Code:</p>

<pre><code>void setup() {
  pinMode(13, OUTPUT);
  pinMode(7, OUTPUT);
}

void loop() {
  digitalWrite(13,1);  
  digitalWrite(13,0);
}
</code></pre>

<p>See circuit below:</p>

<p><a href="https://i.stack.imgur.com/HB452.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/HB452.jpg" alt="enter image description here"></a></p>
 10794: <p>Try adding a delay into your loop. In your code pin 13 will toggle very rapidly, much too fast to see it. For example:</p>

<pre><code>void loop() {
  digitalWrite(13,HIGH);  
  delay (1000);
  digitalWrite(13,LOW);
  delay (1000);
}
</code></pre>

<hr>

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

<p><a href="https://i.stack.imgur.com/rk0xf.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/rk0xf.png" alt="Low-side driver"></a></p>
