I'm working on a project where I'm trying to control 5 LED strips using MOSFETs (specifically RFP30N06LE). Almost everything is working perfectly. When I apply a 5V signal (using 5V header on Uno) to the gate of the MOSFET, it switches on, and the LED strip turns on. The trouble is, for some reason, the digital output pins are only outputting ~1.4V. This is only the case when the MOSFETs and LEDs are attached, otherwise they do output 5V.
I've read something about large loads causing the voltage of the output pins to drop, but I'm not sure if that's my problem. The Uno is only powering the MOSFET gate, so I think it shouldn't be carrying a high load? For reference, each LED strip draws about 45mAh (edit: meant mA) not including the MOSFET (I'm not sure how that would affect it).
I've attached a diagram showing my wiring which may help (imagine an led strip in place of the led) I'm very new to working with electronics so I might be missing something very simple and obvious, so please point out anything you see!
I was using some very simple test code. Do I need to specifically set it as an output? I assumed that was the default state. Here's all of my test code.
Is the 5V power supply holding-up, or is that voltage dropping too?
That's "odd" for an LED strip. Typically, a single LED is about 20mA (or less), or with RGB LEDs about 20mA per-color. So I'd expect more from an LED strip.
Right! If it's wired correctly (and your drawing looks OK) the current-path is through the MOSFET and power supply so the Arduino only has to supply a tiny current to the MOSFET & 10K resistor.
The MOSFET might be bad, or it might be wired wrong (maybe the Arduino isn't connected to the gate). Or, maybe that's not really a 10K resistor....
If all pins were set to OUTPUT as default, then on reset, they would all be locked to the negative rail until otherwise programmed. That would cause major problems with whatever devices you connected to them to be controlled, let alone devices connected to be used as inputs.
The default state is neither INPUT nor OUTPUT, rather it is 'floating' as the CMOS has a tristate configuration. Three-state logic - Wikipedia
Some Arduino documentation refers to the high-impedance input mode (default) and differentiates to the digitalWrite(pin, HIGH) which enables the weak pullup internally. Thus the initial state in the sketch phase is INPUT high-Z and thus pinMode(pin, INPUT) is redundant in code but is more for explicit documentation of the pin state.
Sounds like a contradiction? Actually, I think it proper to think of digital inputs being neither input or output from a "student" prospective. The input pin is high-Z and can neither source or sink a digital signal. The act of reading the input then determine the logic level of the input signal.
It is almost analogous to the "if a tree falls in the woods and no one is around, does it still make a noise?"
Later, I go on to say that I believe it is good practice to set pinMode() to INPUT as a clear understanding of program logic, a kind of self-documentation.
The other reason I wrote as I did is because Arduino documentation is wishy-washy to a degree on the use of terminology. This is commonplace these days with CMOS uC's being the most common chips used by hobbyists; certainly not what was written back in the day of nMOS or TTL logic.
So, thank you. Hopefully I have done a decent explanation to why the statements seem to contradict.
And the reference to "TTL" is in itself a problem, as TTL logic levels are totally inappropriate for 5 V CMOS logic and the term as often used is simply incorrect and misleading!