Mini Braitenberg vehicle

Here is the second incarnation of a Braitenberg vehicle. This one is almost half of the size of the previous one and it is programmed to “love”. That means it sticks to the light source and does not try to overrun it, as the “aggressive” first one.

If it is dark, then the two motors run at full speed. If a sensor detects light, it slows down the motor on the same side. So, if the right sensor detects more light than the left sensor, the right motor turns slower than the left one. That makes the vehicle turn right to the light source. If it is bright enough, both sensors will stop both motors.

Parts

I picked the Arduino Mini Pro because of it’s size and because it runs at 3.3V, a good match with the 3.7V lipo cell. The lipo cell has about the same size as the mini breadboard. The two servos are hacked for continuous rotation and tied together, bottom to bottom with a piece of wire. Although most servos are rated for 5V, they work great with 3.7V. Maybe they run a bit slower.

Code

/*
 * Simple braitenberg vehicle
 */
#include "Servo.h"

Servo leftServo;
Servo rightServo;
int leftValue = 0;
int rightValue = 0;

void setup() {
  Serial.begin(9600);
  leftServo.attach(10);
  rightServo.attach(9);
}

void loop() {
  // sensor values between 50..900
  leftValue = (880 - analogRead(1)) / 25;
  rightValue = (900 - analogRead(0)) / 30;
  leftServo.write(101 + rightValue);
  rightServo.write(101 - leftValue);
  delay(10);
}

The values are determined by experiments. Yours may vary.

Here is the mini next to his older brother. The space on the mini breadboard is really limited, but it just works out. Still no soldering required, if you don’t count the servo hacking.

What’s next? Hm, pager motors?

Links

7 thoughts on “Mini Braitenberg vehicle

  1. I have tried this, and it does not work at all. Here is how I have it connected… 3.7v to vcc, gnd to gnd – also goes to a bus grounding both motors. Power goes from the battery through each eye, then a resistor to the gnd bus. The pwm of each motor is connected to pin 9 and 10, respectively. Between the eye and the power it is connected to pins a0 and a1.

    All my connections look just like yours, I believe. the board powers on, but will not move the robot. the servos function as well if you apply power directly.

    Sorry for the questions, but I am new to this, and I really liked your example.

    -Nathan

    Like

  2. Hi Orntar,
    just write a loop for the Arduino, that sends value 70…120 to the servo motors.
    For the LDRs, just print out the values you receive.
    With this you should find out, why the motors are not working.
    Cheers,
    Alex

    Like

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s