-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathfinal_Ov_UvProtection.ino
More file actions
60 lines (53 loc) · 1.16 KB
/
Copy pathfinal_Ov_UvProtection.ino
File metadata and controls
60 lines (53 loc) · 1.16 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
#include <LiquidCrystal.h>
#define rs 12
#define en 11
#define d4 5
#define d5 4
#define d6 3
#define d7 2
#define HIGH 0x1
#define LOW 0x0
LiquidCrystal lcd(rs, en, d4, d5, d6, d7);
String TextForSms ;
int analogInput = A1;
float vout = 0;
//int vin = 0;
int relay = 7;
int value = 0;
float vol = 0;
void setup() {
Serial.begin(9600);
// set up the LCD's number of columns and rows:
lcd.begin(16, 2);
// Print a message to the LCD.
lcd.print("Voltage:");
pinMode(relay, OUTPUT);
pinMode(analogInput, INPUT);
}
void loop()
{
// read the value at analog input
value = analogRead(analogInput);
vout = (value / 1023.0)*5.0;
vol = vout*100;
lcd.setCursor(10,0);
lcd.print(vol);
if (vout > 2.6)
{
digitalWrite(relay,LOW);
lcd.setCursor(0,1);
lcd.print("Overvoltage");
}
if (vout<2.0)
{
digitalWrite(relay,LOW);
lcd.setCursor(0,1);
lcd.print("Undervoltage ");
}
if ((vout > 2.0)&&(vout<2.6))
{
digitalWrite(relay,HIGH);
lcd.setCursor(0,1);
lcd.print("Normal Voltage ");
}
}