Let's Make Robots!

Loosing power when read incoming serial signal from XBee

Have any of you seen the problem when you start getting signal from Xbee and lose the power?

this is the code I have:



void loop(){

  if(Serial.available() > 0) {





Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.

ok. I don't think your loosing power. Sounds like the serial library and the servo library are conflicting. When the servos stop receiving pulses they stop trying to maintain a position.

Hum... Not sure where do I start. I tried softwareServo as IG suggested but it's not moving at all, perhaps I didn't do it right? Also tried #include <MegaServo.h> but it's the same as Servo library.

I suggested it as a sort of blind recommendation without a detailed review of your code. If there is a conflict between timers in your programming, Software.Servo might have resolved it.

I don't want to send you down a rat's hole, but if you think this could be the issue, it might be worth it. Write a quick test program using Software.Servo that does nothing else but move a servo or two. Once you have an understanding of this library in isolation, try again to integrate it to the larger program.

Note that as documented on the Arduino web page you linked, you need to reissue the Software.Servo commands periodically. This is different than the normal Servo library.

You might try re-writing the code to use the software.servo library. I think it uses a different timer, and perhaps it will not have the conflict with the serial library.

Do you mean this one?


Let me try it now~ Thanks! 

I don't really know how to describe but I will try my best. I connect them with single 2S LiPo thru 6V UBEC into both Arduino and the Shield. Here is the Shield I am using:

The board itself provide 3.3 in XBee slot. Following is the UBEC I use to reduce the current to 6V. (Ignore the black chassis)

I also try to connect 2 different battery but still same thing.

Something interesting thou. The code I use:

  void loop(){

if(Serial.available() > 0) {

If I comment out if(Serial...  just leave assignVar(); it works. Seems like it doesn't like Serial.avaliable()

This code causing the problem, but this works:

  void loop(){

char val = Serial.read();
  switch(val) {
  case '4'://Move

When all servos power out, it try to connect it back but as long as I keep the XBee on remote on it gets power out right that way.


Are you loosing power or is it just causing the processor to reset? How are you translating between the 3.3V of the Xbee and the 5V of the arduino mega?