Inspiration The movie Wall-E

What it does This robot scans from left to right until it holds onto its closest target. Once tracked, it senses its surroundings and follows the target around.

How I built it

The base of the robot is the Zumo 32U4. It consists of a built-in Arduino-compatible ATmega32U4 micro controller. We programmed the robot using Arduino software and made electrical connections to an external ultrasonic sensor for the robot to detect its surroundings. We made electrical connections to the sensor using header wires and a breadboard, mounted on top of the Zumo 32U4 using foam, popsicle sticks, rubber bands, and a toothpick.

Challenges I ran into

Completing the mechanical design so that it would be stable and also resemble the beloved Pixar character Wall-E was a great challenge. Getting the programming to work was also a very tough challenge.

Accomplishments that I'm proud of

We were required to mathematically calculating the required arc length to find the angle at which the robot would have to turn. Creating this algorithm was an accomplishment that we were proud of.

What I learned

Robots do exactly as they are programmed. Therefore, it's essential to be very careful and do a lot of testing to make sure there are no bugs in the code.

What's next for Wall-E

Perhaps allowing Wall-E to act as an alarm clock and display the time. Possibly adding music or even creating Eva would also be a consideration for the future.

Code

#include <Ultrasonic.h>
#include <Servo.h>
#include <Wire.h>
#include <Zumo32U4.h>

#define TRIGGER_PIN  13
#define ECHO_PIN     16
#define SERVO_PIN   15
#define MAX_DISTANCE 200

Zumo32U4Motors motors;
Ultrasonic ultrasonic(13,16,MAX_DISTANCE*58); // (Trig PIN,Echo PIN)
Servo myservo;
unsigned int distance;
unsigned int closest_distance;
int target_angle;

void setup() 
{
  closest_distance = 200;
  target_angle = 90;
  myservo.attach(SERVO_PIN);  
  Serial.begin(115200);
  motors.setSpeeds(0,0);
}

void loop()
{
  fullScan();
  myservo.write(target_angle);
  delay(2000);
}

void fullScan(void)
{
  int angle;
  resetMotor();
  motors.setSpeeds(0,0);
  for (angle=180;angle>=0;angle-=36)
  {
    myservo.write(angle); 
    delay(200);
    getDistance();
    if (closest_distance>=distance && distance!=0)
    {
      closest_distance = distance;
      target_angle = angle;
    }
  }
}

void resetMotor(void)
{
  myservo.write(180);
  delay(500);
}

void getDistance(void) 
{
  delay(50);
  distance = ultrasonic.Ranging(CM);
}

Built With

Share this project:
×

Updates