Uno not outputting 5V on output pins (I'm new)

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!

ARDUINO

post the code? did you make sure to set the pins as OUTPUT?

Did you remember to set the pins to be outputs?

"mAh" is a measure of battery capacity.

I try to leave pin 13 spare if I can - it's handy for debug

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.

void loop() {
digitalWrite(1,HIGH);
digitalWrite(2,HIGH);
digitalWrite(3,HIGH);
digitalWrite(4,HIGH);
digitalWrite(5,HIGH);
digitalWrite(8,HIGH);
digitalWrite(9,HIGH);
digitalWrite(10,HIGH);
digitalWrite(11,HIGH);
digitalWrite(12,HIGH);
}

Sorry, I meant mA, measured with a multimeter. On the real life project, I'm currently using pin 13 for a button.

Yes. https://docs.arduino.cc/built-in-examples/basics/Blink

pinMode(1,OUTPUT)
...

In setup() you must tell the program you intend to use the specific pin as an OUTPUT:
pinMode() - Arduino Reference

void setup() {
     pinMode(1, OUTPUT) ;
     pinMode(2, OUTPUT) ;
     pinMode(3, OUTPUT) ;
     pinMode(4, OUTPUT) ;
     pinMode(5, OUTPUT) ;
     pinMode(6, OUTPUT) ;
     pinMode(7, OUTPUT) ;
     pinMode(8, OUTPUT) ;
     pinMode(9, OUTPUT) ;
     pinMode(10, OUTPUT) ;
     pinMode(11, OUTPUT) ;
     pinMode(12, OUTPUT) ;
}

void loop() {
digitalWrite(1,HIGH);
digitalWrite(2,HIGH);
digitalWrite(3,HIGH);
digitalWrite(4,HIGH);
digitalWrite(5,HIGH);
digitalWrite(8,HIGH);
digitalWrite(9,HIGH);
digitalWrite(10,HIGH);
digitalWrite(11,HIGH);
digitalWrite(12,HIGH);
}

AND DO NOT expect exactly the battery plus voltage as there is a small barrier loss in the CMOS logic.

Logic Levels - learn.sparkfun.com

1 Like

...but you must spell "void" correctly.
(And leave pins 0 and 1 untouched)

Not all. That won't compile because setup() is not defined.

Not a good idea to use pin 1 on Uno, it's needed for sketch upload and serial monitor. If you need, you can use the analog pins as digital outputs

1 Like

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....

Thank you so much! Setting the pins as outputs worked! Sadly, I'm having other issues now, but I will try to figure those out...

Work through issues methodically ... you can block-out large sections of code by using block multi-line comments:

/*
   line 1
   line 2
   line n
*/

Have a think about it!

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. :astonished:

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.

More here

but

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.

Ray

That would be right!

Absolutely. :+1:

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! :roll_eyes:

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.