Monday, March 16, 2015

He's Alive! (Again)

Indeed, I had a power problem - but not only that, I also had a coding problem and it has taken me weeks to figure out how to proceed.

I completely disasembled the bot several time and finally figured out how to power each servo motor independently because a single 9v didm't provide enough power to move three motors and the sensor.

Then I went back to the simples version of my code. In this version, the ultrasonido sensor is not yet live because I just wanted to get everything actually working before I try to manipulate it to do specific actions.

Next Steps:

  • walk forward
  • detect an object
  • look left then right
  • determine the best course foward to avoid the obstacle 

But for now, I feel this sense of relief that I can finally move forward with new code as everything is functioning. 

Meet BB2A.



And here is the code for this iteration. 


#include <Servo.h> 

Servo frontServo;
Servo backServo;
Servo neckServo;

int centerPos = 90;
int frontRightUp = 72;
int frontLeftUp = 108;
int backRightForward = 75;
int backLeftForward = 105;

int lookLeft = 15;
int lookRight = 90;


void moveForward()

frontServo.write(frontRightUp);
backServo.write(backLeftForward);
delay (125);
frontServo.write(centerPos);
backServo.write(centerPos);
delay (65);
frontServo.write(frontLeftUp);
backServo.write(backRightForward);
delay (125);

frontServo.write(centerPos);
backServo.write(centerPos);
delay (65);

void sweep()
{

neckServo.write(centerPos);
delay (125);
neckServo.write(lookLeft);
delay (125);
neckServo.write(centerPos);
delay (125);
neckServo.write(lookRight);
delay (125);
}

void setup() 
  frontServo.attach(2); 
  backServo.attach(3);  
  neckServo.attach(6);
  } 

void loop() 
{
     moveForward();
     delay(150);
     sweep();
     delay(150);

}  

Monday, February 23, 2015

Power Problem?

I took several videos yesterday of BB1B avoiding obstacles and studied them last night. What I learned was that BB1B couldn't "see" left or right to determine which way was the best way to turn. I don have extra ultrasonic sensors to add, so I decided to add an extra serio motor so that the one  ultrasonic sensor I do have could swing to the left and right to see obstacles with the hopes of programming it later make decisions based to determine the best route to take to navigate a mate.

Well... in theory it is going to work, but I have run into my own obstacle...


As you can see in the above video of BB1C (new version, new name) it seems that 3 servos and a (((PING sensor is too much for a 5v USB or a 9v battery. hmm.

I am just guessing it is the power supply. I can tell that the code is correct as everything works independently. Of course, I don't have a variety of power supplies to use as a test platform, so I will have to put it away until I can find a new power source. 

Also, it also ocurred to me that the 4 devices might be too much for the board and that maybe I should add another arduino board... but some basic research suggests I should be able to run up to 8 devices from a single arduino Uno so I am going with the power supply first.  

Sunday, February 22, 2015

Avoiding Obstacles


I've had to take a couple of weeks off because of work and admittedly it took quite a bit of time to move BobbyBot from dancing a jig to something that resembles walking. I made a few modifications mostly to the legs, burned through a bunch of 9v batteries, added an ultrasonic sensor and about 2 more pages of code.

Here is a video of BB1B navigating a simple obtacle course. His only purpose here is to not get stuck which I think he does fairly nicely for my first self propelled robot. 

Sunday, January 25, 2015

BobbyBot's First Steps

Repositioned the legs and added duct tape to the feet for a little grip. I am quite surprised how quickly the Arduino and two servo motors burn a 9v battery. I see now why people buy rechargeable batteries and will be investing in some soon. 

Next steps will include programming BB1A to turn (on purpose) walk backward, program the ultrasonic sensor and then set up an obstacle coarse. :)

But... one step at a time. Here are BobbyBot's first steps.

 

Saturday, January 24, 2015

BobbyBot Comes Alive!

Not quite what I had in mind but BobbyBot is ALIVE!

I still need to finess his legs and maybe some of the code because I want him to walk straight and then I will add the sensor to negotiate obstacles...

I now present to BobbyBot (BB1A) dancing a quick jig. 


And here is the code: 

#include <Servo.h> 

Servo frontServo;
Servo backServo;
int centerPos = 90;
int frontRightUp = 72;
int frontLeftUp = 108;
int backRightForward = 75;
int backLeftForward = 105;
void moveForward()

frontServo.write(frontRightUp);
backServo.write(backLeftForward);
delay (125);
frontServo.write(centerPos);
backServo.write(centerPos);
delay (65);
frontServo.write(frontLeftUp);
backServo.write(backRightForward);
delay (125);

frontServo.write(centerPos);
backServo.write(centerPos);
delay (65);

void setup() 
  frontServo.attach(2); 
  backServo.attach(3);  
  } 

void loop() 
{
     moveForward();
     delay(150);

Monday, January 19, 2015

Prototpye BobbyBot

So, with all of the basic functionality and code in place, it is time to begin prototyping my first robot.

(happy dance)

Using the plans laid out in the Make book  referenced earlier, I have begun my first prototype of my first robot whom I will call, BobbyBot. (named after my dog, of course).

Here he is:



Servo Motors

I am kind of blown away. I sat down to program my first servo motor and in 29 minutes I wired and programmed 2 independently moving motors.


Here is the code:


#include <Servo.h> 

Servo myservo1;
Servo myservo2;

int pos = 0;    

void setup() 
  myservo1.attach(9); 
  myservo2.attach(7);  


void loop() 
  for(pos = 0; pos < 180; pos += 1)  
  {                                  
    myservo1.write(pos);              
    delay(15);  
     myservo2.write(pos);              
    delay(15);  
    // waits 15ms for the servo to reach the position 
  } 
  for(pos = 180; pos>=1; pos-=1)     
  {                                
    myservo1.write(pos);              
    delay(15);   
   myservo2.write(pos);              
    delay(15);       
  }