Voltage problems with digitalWrite

When I digitalWrite(pin,HIGH) I'm only pulling 3.24v.

analogWrite yields a full 4.99v.

Both of which are coming from USB power and even when using an NPN transistor to power the LED from the 5V rail, it only dimly lights when using digital outputs.

This is just my testing code to demonstrate that the analogWrite has full voltage.

Code is as follows:

include

int RECEIVE_PIN = 11; int LEDPIN = 8; int LEDPIN2 = 7; int LEDPIN3 = 6; int state = 0; // 0 = LED off while 1 = LED on IRrecv irrecv(RECEIVE_PIN); decode_results results;

void setup() { Serial.begin(9600); irrecv.enableIRIn(); }

void loop() { if (irrecv.decode(&results)) { switch (results.value){ case 0xFFA25D: if (state ==0) { state = 1; analogWrite(LEDPIN, 255); } else { state = 0; analogWrite(LEDPIN, 0); } break;

case 0xFF629D: if (state ==0) { state = 1; digitalWrite(LEDPIN2, HIGH); } else { state = 0; digitalWrite(LEDPIN2, LOW); } break;

} delay(50); irrecv.resume(); } }

Where do you set LEDPIN2 mode to output?

[quote author=Nick Gammon link=topic=195692.msg1444022#msg1444022 date=1382850849] Where do you set LEDPIN2 mode to output? [/quote]

Thank you for pointing out the derp-iest thing I have ever done :zipper_mouth_face:

The code that I was working with earlier worked fine, and then I started adding and things went all downhill.

Thank you so much for the reminder to go to sleep, Nick!

Cheers,

ADMIN: please delete this thread due to sheer stupidity :P

Absolutely not.

It's good for others to learn from. (sorry)

When I digitalWrite(pin,HIGH) I'm only pulling 3.24v.

Just a reminder you do not pull a voltage you can only pull a current. It might sound pedantic but it is important to think correctly and if you think you are pulling a voltage this is not correct.