Go Down

Topic: Arduino rc robot freezes when unplugged from pc (Read 1 time) previous topic - next topic


Apr 18, 2017, 09:43 pm Last Edit: Apr 21, 2017, 03:10 pm by Dudel
I am building a radio controlled digger. Everything works just fine, but only when plugged to PC. Code works like this

>Read recieved message from transmitter
>Check the third letter
>Is third letter an 'F'?
>Run motors
>Turn motors off

Well, everything is okay, until we unplug the Arduino. In this case it works like this
>Wait for the message
>Message is 'F', run the motors
>Run the motors
>Run the motors
>Run the motors
And it's stuck, won't read any other messages I am sending

I am using Arduino Uno with Motor Shield (Shield powered with 4xAA batteries and Arduino with 9V battery via barrel connector) and 433 MHz XY-MK reciever

This is my code:
Code: [Select]
#include <VirtualWire.h>
#include <AFMotor.h>
AF_DCMotor motor1(3);
AF_DCMotor motor2(4);
char c;
void setup()

void loop()
    uint8_t buf[VW_MAX_MESSAGE_LEN];
    uint8_t buflen = VW_MAX_MESSAGE_LEN;
    if (vw_get_message(buf, &buflen))
      int i;
      String data;
    for (i = 0; i < buflen; i++)
         data +=char(buf[i]);
   c = data[2];
   case 'F':motor1.run(FORWARD);
   case 'L':motor1.run(FORWARD);
   case 'R':motor1.run(BACKWARD);
   case 'B':motor1.run(BACKWARD);
   default: motor1.run(RELEASE);

Someone knows what is the problem? It's slowly driving me mad


Apr 21, 2017, 03:11 pm Last Edit: Apr 21, 2017, 05:07 pm by Dudel
I really need to know what the answer is, please, give me some suggestions and help

EDIT: The same error occurs when the only power I use comes from USB cable


For informed help, please read the "How to use this forum" post and follow the directions.


> Appropriate forum section - checked
> Correct language - checked (i'm not speaking fluent english yet but I am trying to write everything correctly)
> Do some research before posting - I've spended 2 days for research before writing this post, checked
> Make a meaningful subject line - checked
> Code tags - checked
> Post in proper sentences - checked
> Detailed description - checked
> Expectations and reality - checked
> Bumps - well, that's my fault but normally people here are getting answers in half an hour, not 3 days

jremington, I am trying to, but I really can't see your point. Can you tell me what do you think is wrong with my post?


You forgot to post a wiring diagram and links to or detailed specifications of the motors and motor shield -- the most likely source of the problem.


Now I see it, my bad!

Shield: adafruit l293d motor shield: https://learn.adafruit.com/adafruit-motor-shield/overview
Motors: I couldn't find the exact specification of motors used, but they are taken from this chassis http://www.ebay.ie/itm/2WD-Smart-Robot-Car-Chassis-Kits-Arduino-2-motor-1-48-Speed-encoder-Battery-Box-/272638065426?hash=item3f7a7ebb12:g:3ocAAOSwvKtY-C3S

I will post the wiring diagram later in this post

Problem is now solved. All I had to do was replace 4xAA batteries with another 9V battery. The problem was lack of power for the motors

Thank you all for help


Problem is now solved. All I had to do was replace 4xAA batteries with another 9V battery.
You'd have done better to replace the 4xAA with 6xAA, if by "9V battery" you mean a PP3 smoke alarm battery.


Yes, I am using PP3 batteries. I know that their lifespan is equal to the lifespan of a fly, but I have no room (or battery basket) for 6 AA batteries in my project. I think good solution would be nimh or another rechargeable accumulators but this would provide further research and some money investment, so, maybe later but for now I will stick with casual PP3s


The battery life comes from (in part) the available amperage in those batteries, @AWOL is very very right when he says that AAAs would be better. Also the motors in other situations may stall out easier by pulling too much current as they get near stalling AKA browning it out atleast in part. A final note is that it'll help your "project piggy bank" if you switch them due to a longer battery life, and AAAs are much cheaper and in ready supply in comparison to those clunky PP3s

Go Up