I am working on a project with an accelerometer and some LEDs, and I have encountered a strange problem getting everything to function while powered via battery.
When I plug in the battery, the code doesn't run (the led's are supposed to be triggered by the accelerometer moving). When I plug the USB in to look into the Serial monitor to debug, everything suddenly works correctly. And when I unplug the usb, it continues to work!
Does anyone know why this may be? Everything seems to be functional as long as it has serial communication with the computer? The battery is connected to Vin and ground with Vin seperated from Vusb (cut), so the USB shouldn't be supplying additional power?
simulate this circuit – Schematic created using CircuitLab