Hi, I’m a beginner when it comes to working with hardware, and a student at UMC. The project that I am attempting is to control a 12v light strip from an Arduino. In order to do this I’m using a 9 volt battery and a BS170-D75Z (Link https://www.digikey.com/en/products/detail/onsemi/BS170-D75Z/1587840?s=N4IgTCBcDaIEIGUCMB2ADAWgCIoKwC0QBdAXyA)
as a way to switch it on and off. How I’ve currently got it wired up is by taking the positive from the LED strip and connecting it to the positive of the battery. Then I have the ground of the battery and ground of the Arduino going to the source of the mosfet. I have the pin 3 going to the gate of mosfet. and I have the ground of the LED strip going to the drain of the mosfet. All my Arduino code is setting pin 3 as an output and then setting it to High waiting 5 seconds and then setting it to low and looping. (Just a basic blink setup) The problem I have is when I plug in the Arduino it will make the lights go bright when on HIGH, but when it goes to LOW it gets pretty dim but doesn’t actually turn off. Do you have any suggestions? I’ve tried a couple different ways to wire it and tried adding some transistors however nothings seemed to make a difference yet. I’ve seen online that people recommend an IRF540N mosfet for Arduino project do you think this could solve my problem?
Thanks for any help.
If I envision your description correctly (schematics are preferred) I would expect a proper switching function to be achievable. The most likely explanations for the observed behavior would appear to be code that is not doing what you think it’s doing, or a physical circuit that is somehow at variance with the mental conception of it.
Measure the gate-source voltage applied to the FET in both states, preferably with a 'scope so as to be able to see things happening on a faster time scale than most typical DMMs can indicate. That should offer some clues.
Thanks for your response,
I tried to create a better diagram on Autodesk however I’ve never used it before so might not be great. I’ll also include a snip of the code I’m using for the Arduino in case you notice anything on that end. Also if you wouldn’t mind explaining or providing a resource on how to go about setting it up the scope that would be amazing. Since to test the voltage I only have a basic Multimeter.
As drawn it would appear that drain and source terminals of the FET are swapped from the arrangement described, which could be a very plausible reason for a “won’t-turn-off” behavior due to the body diode found in most all discrete FETs. Some symbol libraries don’t include this diode in their FET symbols, but I prefer to do so as a reminder of its presence.
Thanks again for the responses I really appreciate it.
Here’s the link I have to the datasheet of the Mosfet the real problem I’m having is that my Mosfet in my breadboard is facing the wires with the flat part forward so it means that drain is left gate is middle and source is right. Is that incorrect? Or did I draw the diagram in a weird way?
In the situation that my understanding of the data sheet is wrong just to clarify this would mean changing the battery ground and LED ground to go to the right left side of the Mosfet instead of the right side where the LED ground will be? The other thing I want to quickly clarify would be the line that’s going out from the source and then going in to the drain. Is that like how my LED positive and battery positive in my sketch are connected to each other outside of the rest of the stuff?
Adding the body diode to your diagram would help illustrate the nature of that potential issue; as drawn there would be a path for current flow regardless of applied gate voltage.
The FET pinout should be as documented in the datasheet.
A cleaner representation of a typical circuit of this type might be as follows. On typical flexible LED strips, the resistance is incorporated onto the strip. When connected correctly and the components are undamaged, it works. When it doesn’t work, it’s usually an indication of A) something in the physical circuit being connected (or not) in a way not reflected on the schematic, or B) something being broken. Option (A) tends to be more common in my experience, though (B) will often occur as a direct result. There’s also option (C), wherein the intended behavior of a device is other than what one understands it to be.
Beyond this, there’s little counsel I can offer aside from walking away for a few minutes, coming back, and checking everything with ruthless skepticism. Draw out the voltages you expect to see at each node for both states, measure them, and look for instances where reality diverges from expectation. These are your clues as to what might be amiss.
Alright thanks for all your help. I’ll let you know if I figure out what the root cause was but thanks again for giving some ideas of what to try.
Thanks for all your help in the end I just needed to swap out the mosfet since it must have been fried or something. And now that I have a fresh mosfet in its working perfectly so thanks a lot for all your help.