(Solved!) Low current from Arduino Output (Arduino Start Here robot)

starthere_-_working_now.pde (3491Bytes)


EDIT: LED problem solved thanks to RobotFreak. I forgot to set the pins to output mode using the pinMode command. As RobotFreak points out, the Arduino sets all pins as inputs by default. I added a For loop to set all the pins to outputs, and everything worked great.

void setup() {
  pinMode(13, OUTPUT);  
  for (int pinindex = 0; pinindex < 14; pinindex++) {
     pinMode(pinindex, OUTPUT);  // set pins 0 to 13 as outputs

I have updated the attached code with the working version.

Note that the USB still resets when the board is not connected to external power and the servo is commanded to move. I suspect the servo draws close to 500mA or whatever my laptop's USB port can support.

I'm working on an Arduino version of the Start Here robot. I haven't got all the hardware yet, but I'm testing out the code on my Arduino Mega clone. I've got an LED that I'm using on different outputs to test their state during program operation.

Here's the weird thing. The LED is running really dim. I can barely see it. At first I thought maybe my cheap Chinese knock-off copy of the Mega was having a problem. I had previously tested all the outputs and they were fine. However, when I download the standard "Blink" program to the Mega with the the output pin changed to my LED pin, it works fine.

So now I suspect something in my code is weird. This is where you come in, my friends. ; j

I've attached my code and would appreciate a quick review to see if I've done something foolish. Here's some info on my setup and things I've tried so far.


  • LED and 150 ohm resistor on Output 7 (one of the motor outputs), with other side going to ground
  • Arduino connected to USB port
  • Arduino powered by external wall wart: 12VDC, 2A
  • Dagu mini servo connected to pin 9 (plus power and ground, of course)
  • Sharp GP2Y0A21YK IR sensor connected to Analog pin 0 (pin 54 on Arduino Mega)
  • Attached code pulls all unused Analog ports to HIGH using internal pullups
  • Built in board LEDs are lit up nice and bright



  • LED dim when running on pin 7 or 5 (motor outputs that are high during normal operation)
  • LED lights up bright if I connect to pin 9 in parallel to servo, or directly to board 5V supply
  • Running attached code, if I disconnect the external 12V supply, my computer keeps dropping the USB connection. I suspect I'm drawing more than the 500mA the USB is rated for. Works find with the external supply.
  • Running standard Arduino 'Blink' program with output on pin 8, LED lights up nice and bright.
  • Servo and Sharp sensor seem to work fine.

Stuff I've tested

  • I've tried commenting out the For loop that sets all the internal pullup resistors: no effect
  • I've tried commenting out all the servo commands: no effect
  • I've tried commenting out the Serial.begin command: no effect
  • I've tried phyically disconnecting power to the servo and to the Sharp: no effect
  • I've tried adding a digitalWrite command to set an unused output to HIGH and moved the LED to that output: LED lights dimly
  • I've tried asking for help from you guys: Effect to be determined ; j

If there's a problem with my code, I can't see it. I'm going to try to wire up the SN754410NE motor driver and see if outputs 7,6,5,4 are providing enough current to drive the logic. I'll post an update when I have some results. In the meantime, can anyone check over my code?

I'm also open to any suggestions to changes in my code. I'm pretty new to the Arduino. I'm not trying to do anything fancy with this one yet. Just trying to replicate the posted Start Here robot. I'll elaborate on the code and physical robot design later.


The code is good, it should

The code is good, it should work fine.

Try to connect the LED this way:

- when the pin is Low, connect the LED (and series resistor) from pin to Vcc

- when the pin is High, connect the LED from pin to GND.

I designed a motor driver board some time ago that had a bi-color LED (just 2 pins) that I wired with a series resistor between the motor driver input pins directly and it was working fine, it even fade in at PWM acceleration. So it should work correctly.

I use bright LEDs for my boards so I wire a 1k resistor in series with them. This way the current is kept at a minimum and the LEDs shine brightly.

I just did another test. I

I just did another test. I powered up the board with both USB and external power connected. Then I disconnected the external supply. The USB connection did not drop. However, as soon as I put my hand in front of the Sharp (which causes the robot to stop and turn the servo), the USB dropped. Each time the servo turns, the USB dropped.

Next I commented out all the servo commands. Then when I placed my in front of the servo, I could see the LEDs indicating a stop and look left-right sequence. But the USB didn’t drop because the servo wasn’t in operation.

My conclusion is that the servo is definitely pulling enough current when operating to cause a problem on the USB power. However, since my LED is still dim without the servo, the USB dropping issue may be entirely separate from the dim LED issue.

Good idea.I tried connecting

Good idea.

I tried connecting the LED from VCC to pin 6, which should be LOW when the robot is driving forward (normal operation). Here’s the weird thing… the LED is not lighting at all. At least not perceptively. Since it barely lit when wired from a HIGH pin to GND, it may be that the voltage drop from VCC to a LOW pin is slightly less than in the other direction, and it was enough of a difference to not light the LED.

The LED lights fine wired from VCC to GND instead of VCC to a LOW pin.

New data

I broke out my multimeter, the Swiss Army Knife of troubleshooting. ; j

Pin 7 (normally HIGH) is putting out 4.99V during normal operation. However, when I connect the LED-resistor pair, it drops to 1.76V.

Pin 6 (normally LOW) is putting out 0.75V. When I connect the LED-resistor pair, it goes up to as high as 4.12V.

This is crazy! That same LED-resistor pair work fine in the ‘Blink’ program.

I didn’t see in your program

I didn’t see in your program any initialisation for your IO pins. You must set at least the output pins as output with the pinMode command. If you only call digitalWrite you will only switch the pullUp resistor on and off. All pins are inputs by default.

1 Like

That was it! So obvious!.

That was it! So obvious!. Thanks, RobotFreak.

I was going to say that

I was going to say that perhaps you missed to declare the pin Output, but I see you already got that advice and that was the problem. The good part about this forums is that you don’t have to wait for one person to get back from work or wake up to help you out, there are so many other knowledgeable people online almost all the time. I really love it.


BTW, one of my motors is running faster than the other. I use PWM to slow it down so the robot drives straight. Look at my code to see how that works.

that was the help i needed and made my day - thanks a lot.
sometimes it’s not so easy to read the own code without a bit of blindness :slight_smile:

1 Like

These posts here had just saved my life hehe Thank You all