This repository has been archived by the owner on Oct 26, 2023. It is now read-only.
-
-
Notifications
You must be signed in to change notification settings - Fork 0
/
arduinocode.cpp
75 lines (70 loc) · 1.61 KB
/
arduinocode.cpp
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
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
int motorDer = 5;
int motorIzq = 6;
int ldrDer = A0;
int ldrIzq = A1;
int ValLdrDer = 0;
int ValLdrIzq = 0;
int sensorpir = 12;
int ledVerde3 = 8;
int ledVerde4 = 9;
int ledRojo2 = 10;
int ledRojo1 = 11;
void setup() {
pinMode(motorDer, OUTPUT);
pinMode(motorIzq, OUTPUT);
pinMode(sensorpir, INPUT);
pinMode(ldrIzq, INPUT);
pinMode(ldrDer, INPUT);
pinMode(ledRojo1, OUTPUT);
pinMode(ledRojo2, OUTPUT);
pinMode(ledVerde3, OUTPUT);
pinMode(ledVerde4, OUTPUT);
Serial.begin(750);
}
void loop() {
ValLdrDer = analogRead(ldrDer);
ValLdrIzq = analogRead(ldrIzq);
Serial.println(ValLdrDer);
Serial.println(ValLdrIzq);
if(ValLdrDer > 750) {
digitalWrite(motorIzq, HIGH);
digitalWrite(8,HIGH);
digitalWrite(9,HIGH);
digitalWrite(10,LOW);
digitalWrite(11,LOW);
}
else;{
digitalWrite(motorIzq, LOW);
digitalWrite(11,HIGH);
digitalWrite(10,HIGH);
digitalWrite(9,LOW);
digitalWrite(8,LOW);
}
if(ValLdrIzq > 750){
digitalWrite(motorDer, HIGH);
digitalWrite(8,HIGH);
digitalWrite(9,HIGH);
digitalWrite(10,LOW);
digitalWrite(11,LOW);
}
else;{
digitalWrite(motorDer, LOW);
digitalWrite(11,HIGH);
digitalWrite(10,HIGH);
digitalWrite(9,LOW);
digitalWrite(8,LOW);
}
if(digitalRead(sensorpir)== HIGH){
Serial.println("Detectar movimiento por el sensor PIR");
digitalWrite(9,HIGH);
digitalWrite(8,HIGH);
digitalWrite(10,LOW);
digitalWrite(11,LOW);
}
else(digitalRead(sensorpir)== LOW);{
digitalWrite(11,HIGH);
digitalWrite(10,HIGH);
digitalWrite(9,LOW);
digitalWrite(8,LOW);
}
}