-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathSerialMonitor_ReadingIntegers.ino
More file actions
74 lines (60 loc) · 1.48 KB
/
Copy pathSerialMonitor_ReadingIntegers.ino
File metadata and controls
74 lines (60 loc) · 1.48 KB
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
int redBlink;
int yellowBlink;
int greenBlink;
int redPin = 11;
int yellowPin = 7;
int greenPin = 3;
String msg = "The red, yellow, and green led's would blink:";
String msg2 = " respectively.";
int dt = 500;
void setup() {
// put your setup code here, to run once:
Serial.begin(9600);
pinMode(redPin, OUTPUT);
pinMode(yellowPin, OUTPUT);
pinMode(greenPin, OUTPUT);
}
void loop() {
// put your main code here, to run repeatedly:
Serial.println("Please input the blink value for the red Led: ");
while(Serial.available()==0){
}
redBlink = Serial.parseInt();
delay(dt);
Serial.println("Please input the blink value for the yellow Led: ");
while(Serial.available()==0){
}
yellowBlink = Serial.parseInt();
delay(dt);
Serial.println("Please input the blink value for the Green Led: ");
while(Serial.available()==0){
}
greenBlink = Serial.parseInt();
Serial.print(msg);
Serial.print(" ");
Serial.print(redBlink);
Serial.print(", ");
Serial.print(yellowBlink);
Serial.print(", ");
Serial.print(greenBlink);
Serial.println(msg2);
Serial.println();
for(int i = 0; i<redBlink; i++){
digitalWrite(redPin, HIGH);
delay(dt);
digitalWrite(redPin, LOW);
delay(dt);
}
for(int i = 0; i<yellowBlink; i++){
digitalWrite(yellowPin, HIGH);
delay(dt);
digitalWrite(yellowPin, LOW);
delay(dt);
}
for(int i = 0; i<greenBlink; i++){
digitalWrite(greenPin, HIGH);
delay(dt);
digitalWrite(greenPin, LOW);
delay(dt);
}
}