13. Input devices¶
Working in group¶
It is an IR infrared or sensor that is being used as the input device in my project.
Description
An infrared obstacle detector is a device that detects the presence of an object through the reflection it produces in light.
Components
These types of sensors act at short distances. In addition, the amount of infrared light received depends on the colour, material, shape and position of the obstacle, so they do not have sufficient precision to provide an estimate of the distance to the obstacle.
These types of sensors act at short distances. In addition, the amount of infrared light received depends on the colour, material, shape and position of the obstacle, so they do not have sufficient precision to provide an estimate of the distance to the obstacle.
Testing the infrared.
The infrared output led turns on when the hand approaches and turns off when it is withdrawn. As can be seen in the video.
As it is a digital sensor the values would be:
1 Digital = 5 V.
0 Digital = 0 V.
for resistance of 4.9 or 0.49 Ω
Voltage check
The voltage is equal to 4.98 volts equivalent to 5 volts, what is technically indicated is demonstrated.
Individual assignment:¶
Physical implementation.
Keeping the servo motor and infrared connected to the PCB, a practical application is to be created.
The purpose of the application is that, when the person's hand is close, the infrared LED turns on and the servomotor is activated.
Fulfilling the purpose of the application, the following instructions are added:
#define pinServo 1
void servoAttach(byte pin){
pinMode(pin, OUTPUT);
}
void servoWrite(byte pin, byte angle){
int pulseHigh = map(angle,0,180,430,2100);
int pulseLow = 20000-pulseHigh;
for (int i=0;i<50;i++){
digitalWrite(pin, HIGH);
delayMicroseconds(pulseHigh);
digitalWrite(pin, LOW);
delayMicroseconds(pulseLow);
}
}
#define pinButton 0
void setup() {
servoAttach(pinServo);
servoWrite(pinServo, 0);
pinMode(pinButton, INPUT);
}
void loop() {
if (!digitalRead(pinButton)){
servoWrite(pinServo, 90);
delay(3000);
servoWrite(pinServo, 0);
}
}
Taking it to the Arduino and running the application.
Physical execution.
Indeed, the infrared output led is activated or turned on when the hand is at a distance of 4 cm. thus ordering the arm to move, clockwise at 90°, and that, when the arm is withdrawn, it returns to its starting point, as can be seen in the following video:
Natives files¶
Ord | Description | Files |
---|---|---|
1 | App Infrared_sensor | Infrared_sensor.ino |