-
Notifications
You must be signed in to change notification settings - Fork 0
/
code.ino
258 lines (217 loc) · 4.57 KB
/
code.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
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
#include <LiquidCrystal_I2C.h>
#include <Wire.h>
const int trigPin = 5;
const int echoPin = 6;
const int trigPin2 = 7;
const int echoPin2 = 8;
long duration;
int distance,hight,be;
long reading;
LiquidCrystal_I2C lcd(0x27, 16, 2); // set the LCD address to 0x27 for a 16 chars and 2 line display
#include "HX711.h"
// HX711 circuit wiring
const int LOADCELL_DOUT_PIN = 3;
const int LOADCELL_SCK_PIN = 4;
int show = -1,s=0,m=0;
float bm;
float vout,Iout,P,sout,sout1,Iout1,aout;
HX711 scale;
void setup()
{
int error;
pinMode(trigPin, OUTPUT);
pinMode(echoPin, INPUT);
pinMode(trigPin2, OUTPUT);
pinMode(echoPin2, INPUT);
Serial.begin(9600);
Serial.println("LCD...");
//attachInterrupt(pin_irq, IRQcounter, RISING);
be=0;
lcd.clear();
lcd.setBacklight(255);
lcd.setCursor(0, 0);
lcd.print(" health care");
lcd.setCursor(0, 1);
lcd.setBacklight(255);
delay(1000);
// wait on Serial to be available on Leonardo
while (!Serial)
;
Serial.println("Dose: check for LCD");
// See http://playground.arduino.cc/Main/I2cScanner how to test for a I2C device.
Wire.begin();
Wire.beginTransmission(0x27);
error = Wire.endTransmission();
Serial.print("Error: ");
Serial.print(error);
if (error == 0) {
Serial.println(": LCD found.");
show = 0;
lcd.begin(20, 4); // initialize the lcd
} else {
Serial.println(": LCD not found.");
} // if
lcd.print("Health care");
//lcd.setCursor(0, 1);
//lcd.print("monitoring system");
delay(2500);
scale.begin(LOADCELL_DOUT_PIN, LOADCELL_SCK_PIN);
pinMode(9, OUTPUT);
pinMode(2, INPUT);
} // setup()
void loop()
{
s++;
int t=analogRead(A0); //Reading the value from sensor
//t=(t*100)/1023;
t=t/2;
if (digitalRead(2)== HIGH)
{
be++;
}
if(s>180)
{
Serial.print(reading); ///distance/aout/vout/sout/reading
Serial.print(",");
Serial.print(hight);
Serial.print(",");
Serial.print(be);
Serial.print(",");
Serial.print(t);
Serial.print(",");
Serial.print(bm);
Serial.print(",");
Serial.println("0");
be=0;
s=0;
m++;
}
if(m>60)
{
m=0;
}
if((m==1)&&(s<3))
{
lcd.clear();
lcd.setCursor(0,0);
lcd.print("tablet remainder");
digitalWrite(9, HIGH);
delay(1000);
digitalWrite(9, LOW);
}
if((m==2)&&(s<3))
{
lcd.clear();
lcd.setCursor(0,0);
lcd.print("syrup remainder");
digitalWrite(9, HIGH);
delay(1000);
digitalWrite(9, LOW);
}
if((m==3)&&(s<3))
{
lcd.clear();
lcd.setCursor(0,0);
lcd.print("medicine before");
lcd.setCursor(0,1);
lcd.print("food alert");
digitalWrite(9, HIGH);
delay(1000);
digitalWrite(9, LOW);
}
if (scale.is_ready()) {
reading = scale.read();
reading=reading/10000;
reading=reading;
// Serial.print("HX711 reading: ");
//Serial.println(reading);
}
digitalWrite(trigPin, LOW);
delayMicroseconds(2);
digitalWrite(trigPin, HIGH);
delayMicroseconds(10);
digitalWrite(trigPin, LOW);
duration = pulseIn(echoPin, HIGH);
distance= duration*0.034/2;
digitalWrite(trigPin2, LOW);
delayMicroseconds(2);
digitalWrite(trigPin2, HIGH);
delayMicroseconds(10);
digitalWrite(trigPin2, LOW);
duration = pulseIn(echoPin2, HIGH);
hight= duration*0.034/2;
reading=reading*2;
hight=200-hight;
float hei=hight;
bm=hei/100;
bm=(reading/(bm*bm));
lcd.clear();
lcd.setCursor(0,0);
lcd.print("W ");
lcd.print(reading);
lcd.setCursor(4,0);
lcd.print(" H ");
lcd.print(hight);
lcd.setCursor(10,0);
lcd.print(" HB ");
lcd.print(be);
lcd.print(" ");
lcd.print(bm);
lcd.setCursor(0,1);
lcd.print("d ");
lcd.print(distance);
lcd.setCursor(6,1);
lcd.print(" T ");
lcd.print(t);
lcd.setCursor(12,1);
lcd.print(s/3);
lcd.setCursor(15,1);
lcd.print(m);
lcd.print(" ");
//lcd.print(reading);
// Serial.print(Iout1);
// Serial.print(",");
delay(333);
if(reading>10)
{
delay(1000);
lcd.clear();
lcd.setCursor(0,0);
lcd.print("BMI ");
lcd.print(bm);
delay(2000);
if(bm<19)
{
delay(1000);
lcd.clear();
lcd.setCursor(0,0);
lcd.print("under weight");
delay(2000);
}
if(bm>27)
{
delay(1000);
lcd.clear();
lcd.setCursor(0,0);
lcd.print("over weight");
delay(2000);
}
if((bm<27)&&(bm>19))
{
delay(1000);
lcd.clear();
lcd.setCursor(0,0);
lcd.print("normal weight");
delay(2000);
}
}
if(distance<15)
{
digitalWrite(9, HIGH);
delay(1000);
}
else
{
digitalWrite(9, LOW);
}
}