Little IR Detection Robot – EL2ISA2


This is a tiny little IR detection robot built by [lumi]. It can explore around, avoid obstacles and make beep sounds when detects a object.

original post from http://letsmakerobots.com/node/31848

littlt IR detection Robot

It uses ATTiny85 chip as it’s brain, and it uses L293D chip to drive the two small gear motors. The power source is just one 3.7V/200mAh LiPo battery.

[lumi] said in his post about this robot:

Again, it’s a proof of concept what can be done with the ATTiny and some other components. Right now it’s just doing the test program and driving around by changing the direction each 2 seconds. The tricky thing is, I just have one I/O pin left for a sensor. Later (probably tomorrow) I will try to get an IR sensor working. It’s a TCRT5000, similar to the Sharp but much smaller. Any suggestions with that? Or just use a pair of IR LEDs?

Here are some images of how he made this robot.

Gear motors

littlt IR detection Robot

DIY PCB board.

He did not have a 16 pin socket for the L293D so he combined and made this multi-chip-socket for ATTiny85 and L293D. Very clever.

IMG_4152k

Cabling at the back.

littlt IR detection Robot

Assembling.

littlt IR detection Robot

All put together in the can. There is still space.

littlt IR detection Robot

IR Sensor

This is the sensor he used.

littlt IR detection Robot

 

Battery

The LiPo 3.7V/200mAh battery can keep the robot going for almost 2 hours.

Making the Beeping sound with AtTiny Chip

Found the code for the sound function here: http://web.media.mit.edu/~leah/LilyPad/07_sound.html

He used a sound module.  It’s not holding the recorded sound when the power is off, so he attached a small LiPo 3.7V/70mAh on it to feed it permanently. One motor pin for the right motor reverse function acts as a trigger. When forward is LOW then it triggers the sound. The sound module and the Attiny shares a common ground.

Recording sound with the microphone sucks since the quality and volume is very low. So he just plugged it into the earphone plug of the computer and recorded it with volume set to 20%.

Source Code for this project:

/***************************************************/
/////////////////////////////////////////////////////
///    EL2ISA2                                    ///
///                                               ///
///    Brain: ATTiny85                            ///
///                                               ///
///    Code version 1.0.1                         ///
///    -> forward, left turn, right turn,         ///
///    -> stop, reverse                           ///
///    -> Infrared eye, LEDs                      ///
///                                               ///
///    by Lutz Michaelis, März 2012               ///  
///    more about this robot and contact form:    ///
///    http://letsmakerobots.com/node/31848       ///
///    powered by                                 ///
///    http://www.roboter-selbstgebaut.com        ///
///                                               ///
///    This code is in the public domain.         ///
///                                               ///
/////////////////////////////////////////////////////
/***************************************************/
int motorPinRF = 0;
int motorPinRB = 1;
int motorPinLF = 3;
int motorPinLB = 4;
int sensorValue;

void setup() {
  //Serial.begin(9600);
  pinMode(motorPinRF, OUTPUT);
  pinMode(motorPinRB, OUTPUT);
  pinMode(motorPinLF, OUTPUT);
  pinMode(motorPinLB, OUTPUT); 
}

void forward(){  //  both motors forward
  digitalWrite(motorPinRF, HIGH);
  digitalWrite(motorPinLF, HIGH);
  digitalWrite(motorPinRB, LOW);
  digitalWrite(motorPinLB, LOW);
}

void reverse(){  //  both motors reverse
  digitalWrite(motorPinRF, LOW);
  digitalWrite(motorPinLF, LOW);
  digitalWrite(motorPinRB, HIGH);
  digitalWrite(motorPinLB, HIGH);
}

void right_turn(){  //  left motor forward, right motor backward
  digitalWrite(motorPinRF, LOW);
  digitalWrite(motorPinLF, HIGH);
  digitalWrite(motorPinRB, HIGH);
  digitalWrite(motorPinLB, LOW);
}

void left_turn(){  //  right motor forward, left motor backward 
  digitalWrite(motorPinRF, HIGH);
  digitalWrite(motorPinLF, LOW);
  digitalWrite(motorPinRB, LOW);
  digitalWrite(motorPinLB, HIGH);
}

void stand(){  // all stop
  digitalWrite(motorPinRF, LOW);
  digitalWrite(motorPinLF, LOW);
  digitalWrite(motorPinRB, LOW);
  digitalWrite(motorPinLB, LOW);
}

void loop() {

  sensorValue = analogRead(1);  // IMPORTANT: on the ATTiny85 the analog input for this input PIN is leg #7                                    

  if (sensorValue < 900)  // check sensor value and do the following when it drops below 900 (app. 3 - 5 cm)
  {
    stand();
    delay (1500);
    reverse();
    delay (800);
    right_turn();
    delay (400);
    left_turn();
    delay (400);
    reverse();
    delay (800);
    left_turn();
    delay (300); 
    reverse();
    delay (200);
    left_turn();
    delay (500);
  }
  else
  {
    forward();  // if nothing in collision range then just go ahead
  }
}
Share Button

Leave a Reply