Introduction: Phoebe the Photophillic Robot

Picture of Phoebe the Photophillic Robot

This is a photophillic --- light-following --- robot. That is, it uses a photosensor to detect the lighting levels on the environment and moves towards the light source. It behaves similarly to your cat when it follows a laser pointer.

Step 1: BoM

Picture of BoM

* Arduino

* Motor Driver Board

* Photoresistor

* Motors

* Wheels

* Castor Wheel -- pivot type

* Foam Board

* Breadboard

Step 2: Chassis

Picture of Chassis

* Cut the foam board to a small square shape piece.

* Glue the two motors to both sides of the foam board.

Step 3: Attach Wheels

Picture of Attach Wheels

* Attach the wheels to the motors, it should fit in snugly.

* Glue a pivot castor when to the tip of the robot.

Step 4: Motor Driver Connections

Picture of Motor Driver Connections
  1. Connect the first motor's pins to pins 4 and 5 of the motor driver board.
  2. Connect the second motor's pins to pins 6 and 7 of the motor driver board.
  3. Connect the motor driver board's pin 1 to the red power rail and pin 5 to the black power rail.
  4. Connect the Arduino's pins 8 to 12 to the motor driver board's pins 11 to 15.
  5. Connect the Arduino's pin 5 to the motor driver boards's pin 10. Connect the Arduino's pin 3 to the motor driver board's pin 16.

Step 5: LDR Wiring

Picture of LDR Wiring

* Connect one of the pins to the ground pin on the Arduino

* Connect the other pin to both a 10k Ω resistor and to 3.3V in parallel.

* Glue it to the tip of the robot.

Step 6: Code

Picture of Code
//motor A connected between A01 and A02
//motor B connected between B01 and B02
int STBY = 10; //standby
//Motor A
int PWMA = 3; //Speed control 
int AIN1 = 9; //Direction
int AIN2 = 8; //Direction
//Motor B
int PWMB = 5; //Speed control
int BIN1 = 11; //Direction
int BIN2 = 12; //Direction
void setup(){
  pinMode(STBY, OUTPUT);
  pinMode(PWMA, OUTPUT);
  pinMode(AIN1, OUTPUT);
  pinMode(AIN2, OUTPUT);
  pinMode(PWMB, OUTPUT);
  pinMode(BIN1, OUTPUT);
  pinMode(BIN2, OUTPUT);
}
void loop(){
  move(1, 255, 1); //motor 1, full speed, left
  move(2, 255, 1); //motor 2, full speed, left
  delay(1000); //go for 1 second
  stop(); //stop
  delay(250); //hold for 250ms until move again
  move(1, 128, 0); //motor 1, half speed, right
  move(2, 128, 0); //motor 2, half speed, right
  delay(1000);
  stop();
  delay(250);
}
void move(int motor, int speed, int direction){
//Move specific motor at speed and direction
//motor: 0 for B 1 for A
//speed: 0 is off, and 255 is full speed
//direction: 0 clockwise, 1 counter-clockwise
  digitalWrite(STBY, HIGH); //disable standby
  boolean inPin1 = LOW;
  boolean inPin2 = HIGH;
  if(direction == 1){
    inPin1 = HIGH;
    inPin2 = LOW;
  }
  if(motor == 1){
    digitalWrite(AIN1, inPin1);
    digitalWrite(AIN2, inPin2);
    analogWrite(PWMA, speed);
  }else{
    digitalWrite(BIN1, inPin1);
    digitalWrite(BIN2, inPin2);
    analogWrite(PWMB, speed);
  }
}
void stop(){
//enable standby  
  digitalWrite(STBY, LOW); 
}

Step 7: Enjoy!

Picture of Enjoy!

Plug in the remaining batteries and let it run!

Comments

About This Instructable

295views

7favorites

License:

Bio: Aerospace Engineer working in Software Development with a passion for Hardware.
More by TechMartian:Flying Captain America's Shield - RC PlaneWide Angle ShotsLED Ping Pong With Shift Register
Add instructable to: