-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathScaryArdilla.ino
47 lines (38 loc) · 945 Bytes
/
ScaryArdilla.ino
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
// Scary "Pockets" Chipmunk!
// Circuito
// Pin D3 - Servo
// Pin D2 - Ojo derecho
// Pin D6 - Ojo izquierdo
// Pin A0 - Light Sensor
#include <Servo.h>
Servo headServo;
int lightSensorPin = A0;
int rightEyeLedPin = 2;
int leftEyeLedPin = 6;
//int headServoPin = 3;
void setup() {
headServo.attach(3);
pinMode(rightEyeLedPin, OUTPUT);
pinMode(leftEyeLedPin, OUTPUT);
//pinMode(headServoPin, OUTPUT);
// initialize serial:
Serial.begin(9600);
}
void loop() {
// put your main code here, to run repeatedly:
int lightValue = analogRead(lightSensorPin);
//Medida inicial del sensor de luz
Serial.println(lightValue);
delay(50);
if(lightValue > 350) {
digitalWrite(rightEyeLedPin, HIGH);
digitalWrite(leftEyeLedPin, HIGH);
headServo.write(180);
delay(5000);
} else {
digitalWrite(rightEyeLedPin, LOW);
digitalWrite(leftEyeLedPin, LOW);
headServo.write(0);
delay(5000);
}
}