-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsensorInfrarrojo.ino
More file actions
29 lines (23 loc) · 921 Bytes
/
sensorInfrarrojo.ino
File metadata and controls
29 lines (23 loc) · 921 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
//This code is to use with FC51 IR proximity sensor, when it detects an obstacle it lights the internal LED
//of the Arduino Board, refer to Surtrtech for more information
int sensorIR = 8; //Declaring where the Out pin from the sensor is wired
int led = 12;
int lectura;
void setup() {
pinMode(led, OUTPUT); // setting the pin modes, the "13" stands for the internal Arduino uno internal LED
pinMode(sensorIR,INPUT); // then we have the out pin from the module
Serial.begin(9600);
}
void loop() {
lectura = digitalRead(sensorIR);
Serial.println(lectura);
if(lectura == 1) //Check the sensor output if it's high
{
digitalWrite(led, LOW); // Turn the LED on (Yes by writing LOW)
}
else
{
digitalWrite(led, HIGH); // Turn the LED OFF if there's no signal on the ProxSensor
}
delay(100);
}