1
2
3
4
5
6
7
8int valBrightness = 0;
9int valPressure = 0;
10int valLed = 0;
11
12void setup() {
13 Serial.begin(9600);
14 pinMode(9, OUTPUT);
15 pinMode(6, OUTPUT);
16 pinMode(A0, INPUT);
17 pinMode(A5, INPUT);
18}
19
20void loop() {
21
22 valBrightness = analogRead(A5);
23 valPressure = analogRead(A0);
24
25 if (valBrightness > 850) {
26 (valLed = 25);
27 if ((valBrightness < 850) and (valBrightness > 750)) {
28 (valLed = 60);
29 }
30 if ((valBrightness < 750) and (valBrightness > 450)) {
31 (valLed = 90);
32 }
33 if ((valBrightness < 450) and (valBrightness > 420)) {
34 (valLed = 125);
35 }
36 if (valBrightness < 420){
37 (valLed = 0);
38 if (valPressure > 100){
39 (valLed = 200);
40 }
41 }
42 if (valLed == 25) {
43 digitalWrite (9, HIGH);
44 digitalWrite (6, HIGH);
45 delay (1000);
46 digitalWrite (9, LOW);
47 digitalWrite (6, LOW);
48 delay (1000);
49 }
50 if (valLed == 60) {
51 digitalWrite (9, HIGH);
52 digitalWrite (6, HIGH);
53 delay (600);
54 digitalWrite (9, LOW);
55 digitalWrite (6, LOW);
56 delay (600);
57 }
58 if (valLed == 90) {
59 digitalWrite (9, HIGH);
60 digitalWrite (6, HIGH);
61 delay (300);
62 digitalWrite (9, LOW);
63 digitalWrite (6, LOW);
64 delay (300);
65 }
66 if (valLed == 125) {
67 digitalWrite (9, HIGH);
68 digitalWrite (6, HIGH);
69 delay (200);
70 digitalWrite (9, LOW);
71 digitalWrite (6, LOW);
72 delay (200);
73 }
74 if (valLed == 0) {
75 digitalWrite (9, HIGH);
76 digitalWrite (6, HIGH);
77 }
78 if (valLed == 200) {
79 digitalWrite (9, LOW);
80 digitalWrite (6, LOW);
81 }
82
83 Serial.println(valBrightness);
84 Serial.print (valPressure);
85 Serial.print (valLed);
86
87}