Robotic Eye

by PeckLauros in Circuits > Arduino

22635 Views, 39 Favorites, 0 Comments

Robotic Eye

DSC_0404.JPG
Hello, This time I will show an application of the infrared sensor module with Arduino.

This module (composed of a pair of LEDs, a infrared transmitter and a receiver and an IC that generates a frequency modulated) is generally used to detect obstacles in robots.

This module has some advantages over a simple LED emitting LEDs with a photodetector. The principal, in this case is that the emission frequency is modulated, preventing ambient light makes the receiver detect the wrong signal. Also, the construction module that facilitates interconnection and didactic use with the Arduino.

Materials

DSC_0287.JPG
DSC_0288.JPG
DSC_0395.JPG
DSC_0397.JPG
DSC_0399.JPG
DSC_0289.JPG
- An Arduino board

- A sensor shield board

- 3 infrared sensor modules

- A standard servomotor

- A Styrofoam ball

- wires


Mounting

DSC_0402.JPG
DSC_0403.JPG
DSC_0404.JPG
DSC_0405.JPG
Cut the Styrofoam ball to hold the arm of the servomotor, paint the Styrofoam ball in the shape of an eye, fit the servo arm in the eye and fit them into the servo.

Mounting the Shield and Connecting Sensors

DSC_0291.JPG
DSC_0292.JPG
DSC_0406.JPG
DSC_0408.JPG
Mounting the Shield in Arduino, install the sensors with the aid of wires.

Note: The receiver module has 4 pins.

- A 5V

- 1 GND

- 1 OUT

- Enable (works to enable the module when it is without the jumper)

* Be careful not to inveter wires.

How to connect the wires:

Shield  ->  Sensors
 
pin  12 ->  left sensor

pin  11 ->  center sensor

pin  10 ->  right sensor

Mounting the Servo and Programing

DSC_0408.JPG
esq.JPG
centro.JPG
direita.JPG
After the sensors installed, install the servo on pin 9 of the shield, programming and testing.

The eye works as follows: to detect an object in front of each sensor (up to 40 cm, adjustable), the sensor changes state at the exit from Hi to Lo (of 5volts to zero) then the Arduino realize that there was a change state in one of its ports so, according to the software, the servomotor to rotate the eye to the preset position.

This was an application of the didactic use of infrared sensors. Many other applications are possible. The limit is your imagination. Hope you enjoy.

  Software:

#include <Servo.h> // include servo library
Servo pescoco; // create servo object to control a servo
int pos =0;
int irdireita = 10;
int iresquerda = 12;
int ircentro = 11;
int tempo = 50;

void setup (){
pescoco.attach(9); // attaches the servo on pin 9 to the servo object
pinMode (irdireita, INPUT); // set pin irdireita (pin10) as input
pinMode (iresquerda, INPUT); // set pin iresquerda (pin12) as input
pinMode (ircentro, INPUT); // set pin ircentro (pin11) as input
}
void loop(){
int valdireita = digitalRead (irdireita);
int valesquerda = digitalRead (iresquerda);
int valcentro = digitalRead (ircentro);

if (valdireita == LOW){
pescoco.write(180);
pos = (180);
delay (tempo);
}
else if(valesquerda == LOW){
pescoco.write (0);
pos =(0);
delay (tempo);
}
else if (valcentro == LOW){
pescoco.write (90);
pos = (90);
delay (tempo);
}
else {
pescoco.write (pos);
delay (tempo);
}
}