I've been trying to turn on 21W bulb with Protected MOSFETS. But somehow the bulbs are getting high automatically from arduino. I've tried all the hardware related things like pull down with different resistors, but no luck. Is it possible due to separate ground of controller and Switch? Because Switch and bulbs are powered through SMPS of 12V 10A while Arduino through Laptop USB cable. Used this protected mosfet, circuit as given on page no 50 of datasheet.

Following is the code I used.

#include <TimerOne.h>

int LED = 13;
int IN0 = 12;
int IN1 = 11;
int OUT1 = 10;
int OUT2 = 9;
int OUT3 = 5;
int OUT4 = 7;
int OUT5 = 6;
int count = 0;

void setup() {
 pinMode(IN0, INPUT);
 pinMode(IN1, INPUT);
 pinMode(OUT1, OUTPUT);
 pinMode(OUT2, OUTPUT);
 pinMode(OUT3, OUTPUT); 
 pinMode(OUT4, OUTPUT);
 pinMode(LED, OUTPUT);
 digitalWrite(OUT3, LOW);


//void flash_R()
//  digitalWrite(LED, !digitalRead(LED));
//  digitalWrite(OUT3, !digitalRead(OUT3));
//  //digitalWrite(OUT4, !digitalRead(OUT4));
//  if(digitalRead(LED)){
//    Serial.println("ON");
//  }
////  Serial.print("Count Value: ");
////  Serial.println(count++);

void flash_L()
  //digitalWrite(OUT3, LOW);
  digitalWrite(LED, !digitalRead(LED));
  digitalWrite(OUT3, !digitalRead(OUT3));
  //digitalWrite(OUT4, !digitalRead(OUT4));

    //Serial.print("Count Value: ");

void loop() {

  [1]: https://i.sstatic.net/64yyQ.jpg
  • 2
    I'm very interested in your schematics. To answer your question: Unless there is some kind of (optical) isolation, both parts of the circuit need the same ground to act as a reference. This may very well be the cause of your problem and you should correct it as soon as possible. Separate grounds could cause large currents to flow between different parts of your circuit and be really dangerous to your Arduino as well as your laptop.
    – StarCat
    Commented Apr 17, 2020 at 13:42
  • @StarCat for schematic, circuit is same as given in datasheet application cicuit and datasheet link I've shared. For input, simple zener based active high circuit used for 12v to 5v and given to controller. For arduino power supply what if I used same power source as of SMPS which is used to power up bulb and switch. So that Ground of switch and arduino will be same.
    – Fatpanda
    Commented Apr 17, 2020 at 13:53
  • You don't have to use the same power supply as long as the grounds are connected. However, you could use the 12V 10A supply for powering the Arduino as long as it's connected to the external power connector (via a barrel plug). What resistor value did you use in the input circuit in combination with the Zener?
    – StarCat
    Commented Apr 17, 2020 at 14:21
  • First resistor of 4K7(series), then a 4V7 zener, Pull Down resistor of 4K7, 0.1UF cap (all 3 other terminal to ground) then again a series resistor of 47K other end connected to controller pin. I wish to upload whole image of ckt but somehow its not getting uploaded due to some error.
    – Fatpanda
    Commented Apr 17, 2020 at 14:37
  • @StarCat Thank you soo much. Your help really solved my problem. Just one more question, After programming arduino, completely disconnected it from laptop. So, to perform any operations like UART arduino needs to be connected to laptop. So, how advisable it is to connect arduino to both laptop and to SMPS via barrel plug?
    – Fatpanda
    Commented Apr 18, 2020 at 8:17


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Browse other questions tagged or ask your own question.