Laser Chasing/Avoiding Car

Submitted by mschiff on Mon, 03/11/2013 - 22:39
mschiff's picture

Description

For this assignment, I wanted to take the idea of a cat chasing a laser pointer, and make that a toy for people who don't have cats.  The toy is basically a remote control car, except the remote is a laser instead of a radio.  In the final version, which would require more computing power, I am imaging a camera and an on-board computer that tries to locate the laser dot in the image and then center it in the field by moving the wheels.  This would create an effect of the car chasing/avoiding the laser, similar to the way one plays with a cat.  For a first prototype, I built a car that drags itself along (no back wheels yet) when it is hit with a bright enough light.  I used a flashlight for the video only because I don't actually have a laser pointer.

 

Materials

  • Arduino x1
  • Breadboard x1
  • Chassis x1 (I used a thin piece of wood)
  • Motors x2
  • Drive Assembly x1 (available for purchase at hobby stores)
  • Resistor (1K Ohm) x2
  • Photoresistor x1
  • TIP120 Transistor x1
  • Wheels x2 (or more if you feel fancy)
  • Jumper wire
  • 2AA battery pack x1
  • 9V battery pack & barrel plug x1

Code

int avg = 0.0;
void setup() {
  Serial.begin(9600);
  pinMode(6, OUTPUT);
  for (int i = 0; i < 10; i++) {
    avg += analogRead(0);
  }
  avg = avg/10.0;
}

void loop() {
  int bright = analogRead(0);
  Serial.println(bright - (avg+100));
  if(bright > avg+100) { digitalWrite(6, HIGH); }
  else { digitalWrite(6, LOW); }
}

Light Car
0
Your rating: None
Drupal theme by Kiwi Themes.