-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathModel Run time code..txt
288 lines (198 loc) · 8.3 KB
/
Model Run time code..txt
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
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
// Code Developed by Team Excalibur's.
//Mannish.S
//Madhumithaa.S
//Hariharan.R
//Prethikaa.M
// Declaring the pins in Aduriuno Board for LED'S.
//Declaring Global Varibles begining.
int led1 = 6;
int led2 = 9;
int led3 = 11;
int led4 = 10;
int led5 = 5;
// Declaring the pins in Aduriuno Board Light resistance diode (LDR).
int ldr = A5;
//Declaring the pins in Aduriuno Board for IR Sensors.
int ir1 = A0;
int ir2 = A1;
int ir3 = A2;
int ir4 = A3;
int ir5 = A4;
//Declaring variables to find out how much the value costs with and without this method.
int act; // Variable to calculate Current method
int totalcount;
int totalsave;
float Expenditure;
float TotalExpenditure;
float ExpenditureSaved;
float totalSavecount;
float totalvalue; //Variable to find the Amount of money Spent in current Implentation .
float moneysaved; //Variable to find the Amount of money saved.
float billsave;
//Declaring Global Varibles End.
void setup()
{
Serial.begin (9600);
// Input and output Pins.
//LED pins.
pinMode (led1,OUTPUT);
pinMode (led2,OUTPUT);
pinMode (led3,OUTPUT);
pinMode (led4,OUTPUT);
pinMode (led5,OUTPUT);
//LDR Pins.
pinMode (ldr,INPUT);
//IR Sensors Pins.
pinMode (ir1,INPUT);
pinMode (ir2,INPUT);
pinMode (ir3,INPUT);
pinMode (ir4,INPUT);
pinMode (ir5,INPUT);
}
void loop()
{
int count=0; //Local Variable
int savecount=0; //Local Variable
delay(1000);
Serial.print("Next Set:");
Serial.print("\n ");
Serial.print("\tLDR Value :");
Serial.println(analogRead(A5)); // Printing LDR Value.
int ldrStatus = analogRead (ldr); // Storing LDR Value in ldrStatus.
int sensorValue = digitalRead(led1); // Variable to Find if LED1 is On or Off.
int sensorValue1 = digitalRead(led2); // Variable to Find if LED2 is On or Off.
int sensorValue2= digitalRead(led3); // Variable to Find if LED3 is On or Off.
int sensorValue3 = digitalRead(led4); // Variable to Find if LED4 is On or Off.
int sensorValue4 = digitalRead(led5); // Variable to Find if LED5 is On or Off.
//To Turn OFF the Lights when the Environment is Lit LDR Resistance less than Ambinet Light.(In this room > 200).
if (ldrStatus >200)
{
digitalWrite(led1, LOW); //Sets Low.
digitalWrite(led2, LOW); //Sets Low.
digitalWrite(led3, LOW); //Sets Low.
digitalWrite(led4, LOW); //Sets Low.
digitalWrite(led5, LOW); //Sets Low.
Serial.print(" Ambient Light ^-^ ");
Serial.print("\n");
Serial.print("--------------------------------------------------------------------------------------");
delay(2000);
}
//To Turn ON the Lights when the Environment is dark LDR Resistance less than Ambinet Light.(In this room < 200).
else if(ldrStatus < 200)
{
digitalWrite(led1, HIGH);
analogWrite(led1,255/5);
Serial.print("\tLED: ON:");
Serial.println(sensorValue);
digitalWrite(led2, HIGH);
analogWrite(led2,255/5);
Serial.print("\tLED1: ON:");
Serial.println(sensorValue1);
digitalWrite(led3, HIGH);
analogWrite(led3,255/5);
Serial.print("\tLED2: ON:");
Serial.println(sensorValue2);
digitalWrite(led4, HIGH);
analogWrite(led4,255/5);
Serial.print("\tLED3: ON:");
Serial.println(sensorValue3);
digitalWrite(led5, HIGH);
analogWrite(led5,255/5);
Serial.print("\tLED4: ON:");
Serial.println(sensorValue4);
if (analogRead(A0) < 1000)
{
digitalWrite(led1,HIGH);
analogWrite(led1,255);
count=count+1;
act+=1;
}
else
{
digitalWrite(led1,LOW);
analogWrite(led1,255/5);
savecount=savecount+1;
act+=1;
}
if (analogRead(A1) < 1000)
{
digitalWrite(led2,HIGH);
analogWrite(led2,255);
count=count+1;
act+=1;
}
else
{
digitalWrite(led2,LOW);
analogWrite(led2,255/5);
savecount=savecount+1;
act+=1;
}
if (analogRead(A2) < 1000)
{
digitalWrite(led3,HIGH);
analogWrite(led3,255);
count=count+1;
act+=1;
}
else
{
digitalWrite(led3,LOW);
analogWrite(led3,255/5);
savecount=savecount+1;
act+=1;
}
if (analogRead(A3) < 1000)
{
digitalWrite(led4,HIGH);
analogWrite(led4,255);
count=count+1;
act+=1;
}
else
{
digitalWrite(led4,LOW);
analogWrite(led4,255/5);
savecount=savecount+1;
act+=1;
}
if (analogRead(A4) < 1000)
{
digitalWrite(led5,HIGH);
analogWrite(led5,255);
count=count+1;
act+=1;
}
else
{
digitalWrite(led5,HIGH);
analogWrite(led5,255/5);
savecount=savecount+1;
act+=1;
}
totalcount=totalcount+count;
totalSavecount=totalSavecount+savecount;
//totalSave=0.10*savecount;
Expenditure=0.9*totalcount; //5v is number of units , 0.9 is the number of watts Expenditure.
ExpenditureSaved=0.5*savecount; //3.3v is number of units , 0.9 is the number of watts Expenditure.
TotalExpenditure=TotalExpenditure+Expenditure;
totalvalue=(act)*5; // 1kwh=5 Rs , data from Gov website.
moneysaved+=(ExpenditureSaved)*5;
Serial.print("\n\t Count This Loop: ");
Serial.println(count);
Serial.print("\t TotalCount: ");
Serial.println(totalcount);
Serial.print("\t Save This Loop: ");
Serial.println(savecount);
Serial.print("\t Total Save : ");
Serial.println(totalsave);
Serial.print("\t Expentiture of watts:");
Serial.println(Expenditure);
Serial.print("\t Expentiture of watts Saved: ");
Serial.println(ExpenditureSaved);
Serial.print("\t Cost Without this Method: ");
Serial.println(totalvalue);
Serial.print("\t Cost Saved With this Method this: ");
Serial.println(moneysaved);
}
}