Thursday, November 14, 2013

Project LightSeeker2000

Project LightSeeker2000


We plan to create a Photo Sensitive robot who will be able to detect and drive to light sources. We also intend to give this robot the ability to maneuver through obstacles with tracks and make the tracks large enough to encompass the body and therefore allowing it to be flipped yet still able to move.

This is the idea we're going emulate
 
 
We remembered this car when we were younger and this is what we are going to amp this concept up with tracks instead of wheels.
 
 
Currently, we are having a hard time figuring the code out, but this is what we have so far:

const int power = 13; //LED Indicator to ensure power
const int RightMotor = 3;
const int LeftMotor = 5;
const int RightSensor = A0;
const int LeftSensor = A1;
// Variables for void loop
int SensorLeft;
int SensorRight;
int SensorDifference;
void setup()
{
  //Read values
  pinMode(LeftSensor, INPUT);
  pinMode(RightSensor, INPUT);
 
  //Pull-up Resistors
  digitalWrite(A1, HIGH);
  digitalWrite(A0, HIGH);
 
  //Serial Connection
  Serial.begin(9600);
 
  //First Readings
  Serial.println("\nReading Light Sensors.");
 
  //Power LED
  digitalWrite(power, HIGH);
}
void loop()
{
  //Reads and saves value to interger
  SensorLeft = analogRead(LeftSensor);
  delay(50);
  SensorRight = analogRead(RightSensor);
  delay(50);
 
//  Difference of Sensors
  SensorDifference = abs(SensorLeft-SensorRight);
 
  //Sensor Readings for debugging
      //Left Photo Sensor
  Serial.print("Left Sensor = "); //Title
  Serial.print(SensorLeft);       //Value
  Serial.print("\t");             //This is for a tab space
 
      //Right Photo Sensor
  Serial.print("Right Sensor = "); //Title
  Serial.print(SensorRight);       //Value
  Serial.print("\t");              //This is for a tab space
 
      //Difference
     
  //Motion of LightSeeker2000
  if (SensorLeft > SensorRight && SensorDifference > 75)
  {
    digitalWrite(RightMotor, HIGH);
    digitalWrite(LeftMotor, LOW);
    Serial.println("Left");
  }
  if (SensorRight > SensorLeft && SensorDifference > 75)
  {
    digitalWrite(RightMotor, LOW);
    digitalWrite(LeftMotor, HIGH);
    Serial.println("Right");
  }
  else if (SensorDifference < 75)
  {
    digitalWrite(RightMotor, HIGH);
    digitalWrite(LeftMotor, HIGH);
    Serial.println("Forward");
  }
  Serial.print("\n");
}
 
We tried to set this up with just one photosensor and one DC motor to see if the motor would spin, but this did not work. We looked at the com port and saw the photosensor measurements, and the command should be to turn left (the left motor should be off while the right motor is running) yet the motor would not run. We will continue to troubleshoot.


No comments:

Post a Comment