-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsketch_may14a.ino
66 lines (57 loc) · 1.18 KB
/
sketch_may14a.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
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
void setup() {
// put your setup code here, to run once:
pinMode(12, OUTPUT);
pinMode(13, OUTPUT);
pinMode(8, OUTPUT);
pinMode(4, OUTPUT);
Serial.begin(9600);
//digitalWrite(8, HIGH);
//digitalWrite(4,HIGH);
if(analogRead(2) > 0) {
digitalWrite(8, HIGH);
} {
while(analogRead(2) == 0) {
digitalWrite(8,HIGH);
delay(500);
digitalWrite(8,LOW);
delay(500);
}
digitalWrite(8,HIGH);
}
if(analogRead(3) > 0) {
digitalWrite(4, HIGH);
} else{
while(analogRead(3) == 0) {
digitalWrite(4,HIGH);
delay(500);
digitalWrite(4,LOW);
delay(500);
}
digitalWrite(4,HIGH);
}
}
bool runOnce = true;
unsigned long startTime;
unsigned long time;
unsigned long elapsedTime;
bool timerOn;
void loop() {
// put your main code here, to run repeatedly:
if(analogRead(2) == 0){
timerOn = true;
startTime = millis();
digitalWrite(8,LOW);
}
while(timerOn) {
time = millis();
elapsedTime = time - startTime;
delay(1000);
Serial.println(elapsedTime);
if(analogRead(3) == 0) {
digitalWrite(4,LOW);
break;
}
}
timerOn = false;
Serial.flush();
}