Robotics with the BOE Shield for Arduino-Chapter 4-Activity 1-ExampleSketch:ForwardLeftRightBackward

ivanhoeivanhoe Posts: 6
edited 2016-01-12 - 14:07:56 in Learn with BlocklyProp
Hi Guys,


//Edit: 4hrs after 1st post > as mentioned below, all the robot does is move forward and turn left and then it repeats => this happened when the robot was connected to battery pack.

Now, 4hrs later, I tried the code below, powered only by USB > the robot moves, slower, BUT the it moves nicely, according to the code.

Hope it narrows down the issue for a solution to be found. Thanks.


//Edit: 4.5hrs after 1st post> I changed to fresh batteries ( 5 x 1.5V non-rechargeable ) to power the robot > it executes the code & runs smoothly now.

Why does it go bonkers when the batteries are low?


I am new to Robotics. Recently, in Dec last year I got my Parallax BOE-Bot shield with Arduino. Now I am at http://learn.parallax.com/node/219 (re: above subject).
Following the exact same code as the activity, which I typed out, but after successful upload, all the robot does is move forward and turn left and then it repeats.
There is NO Turn right in place and Full speed backward.

Please help. Thank you, Ivan Hoe

Here's the code:

#include<Servo.h>

Servo servoLeft;
Servo servoRight;

void setup() {
tone(4, 3000, 1000);
delay(1000);

servoLeft.attach(13);
servoRight.attach(12);

// Full speed forward
servoLeft.writeMicroseconds(1700);
servoRight.writeMicroseconds(1300);
delay(2000);

// Turn left in place
servoLeft.writeMicroseconds(1300);
servoRight.writeMicroseconds(1300);
delay(1000);

//Turn right in place
servoLeft.writeMicroseconds(1700);
servoRight.writeMicroseconds(1700);
delay(1000);

// Full speed backward
servoLeft.writeMicroseconds(1300);
servoRight.writeMicroseconds(1700);
delay(2000);

servoLeft.detach();
servoRight.detach();
}

void loop() {

}

Comments

  • ivanhoe wrote: »
    Hi Guys,



    //Edit: 4.5hrs after 1st post> I changed to fresh batteries ( 5 x 1.5V non-rechargeable ) to power the robot > it executes the code & runs smoothly now.

    Why does it go bonkers when the batteries are low?


    When batteries are low, the draw of servo motors can cause the voltage to drop enough that the micro resets which starts the program from the beginning until the voltage drops again.

    Does the speaker beep each time before it moves forward? That usually tells me it's time to change batteries.

    Tom

  • @Tom, those time when the robot went crazy, yes, the speaker beeps before it moves. Thanks for the reminder.
  • To get the most out of your batteries, remember to be extra diligent about unplugging the Barrel Plug from the Arduino module anytime the robot is not in active use.

    The module itself is powered anytime it is plugged in, and will slowly drain your batteries even while the BOE Shield power switch is in the 0 or off position.
  • ivanhoeivanhoe Posts: 6
    edited 2016-01-13 - 02:00:27
    @Courtney, thanks for the reminder.
    Initially, I left the Barrel plug on the Arduino module for about 40% of the time, even though the robot is not in use.

    Though I just bought the 8 x AA 1.5V Eveready batteries last sat, 9/1 and ONLY started using them on the 11/1, now these batteries are weak and goes crazy > they run dry too fast.
    Now, I am considering to get re-chargeable batteries.
Sign In or Register to comment.