0
\$\begingroup\$

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?

schematic

simulate this circuit – Schematic created using CircuitLab

\$\endgroup\$
4
  • 1
    \$\begingroup\$ your circuit omits decoupling capacitors on the 7805. Hope this doesn't reflect reality! if it does, the thing might just wildly oscillate when your teensy starts drawing current. \$\endgroup\$ Commented Jun 6, 2020 at 19:18
  • \$\begingroup\$ Yeah, I probably should order them. What kind would I need? \$\endgroup\$
    – Charley
    Commented Jun 6, 2020 at 20:27
  • \$\begingroup\$ Do you have the line " while (!Serial) ;" in your code? I had this issue once when running example code and that was the cause. It waits for serial to be available before continuing. \$\endgroup\$
    – Drew
    Commented Jun 6, 2020 at 22:32
  • 1
    \$\begingroup\$ Why did you think the capacitors were an option? See the datasheet. \$\endgroup\$
    – Transistor
    Commented Jun 6, 2020 at 22:36

1 Answer 1

1
\$\begingroup\$

Do you have while(!Serial); in your code?

Also as mentioned - use capacitors on 7805, I'd suggest 1uF ceramics and maybe a bigger one if you have them too.

\$\endgroup\$
2
  • \$\begingroup\$ Haha just posted exactly the same thing. A bunch of us must have had this issue. \$\endgroup\$
    – Drew
    Commented Jun 6, 2020 at 22:32
  • \$\begingroup\$ Ah! Thank you so much! I feel dumb- there was a line "while (!Serial) delay(10); " from the original accelerometer code I took from. I'll go ahead and order those capacitors too. Without them, are there any harmful effects to the Teensy? \$\endgroup\$
    – Charley
    Commented Jun 6, 2020 at 23:01

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.