Sketch and external power

Greetings all,

I am experiencing a challenging problem. Hope someone will be able to shed some light or give some tips / advice.

When writing / running / testing my sketch it runs 100% fine. As soon as I remove the USB Cable (PC <--> Arduino) the sketch no longer works. It will only continue with whatever is was last busy with.

This started to occur as soon as I added the PIR to my sketch. When my sketch was just the photocell and LED it ran fine (without the USB issue).

The closest similar description I have found to this was here: http://www.arduino.cc/en/Guide/Troubleshooting#toc5


  • Arduino Uno
  • Ubuntu 11.04
  • Arduino IDE

  • PhotoCell
  • PIR
  • LED's
  • 12V PSU

Overview if the sketch:
If lightlevel is below threshold:
->Set LED to dim (analogWrite)
-->If PIR detects motion
--->Fade LED in and keep on for X cycles

Thanks in advance