Arduino ilə dəyişən gərginliyin müşahidəsi, aşırı gərginlik, normal gərginlik və aşağı gərginlik
electronxlab
#include <LiquidCrystal.h>
#define rs 9
#define en 8
#define d4 7
#define d5 6
#define d6 5
#define d7 4
// initialize the library with the numbers of the interface pins
LiquidCrystal lcd(rs, en, d4, d5, d6, d7);
String TextForSms ;
// FOR THE VOLTAGE SENSOR
float correctionfactor = 26; // 77
int analogInput = A1;
float vout = 0;
int vin = 0;
// if we add 428k ohm resistor in series with the module
// we can monitor the line voltage upto 310.048
float R1 = 30000 + 428000; // these are the 30k and 428k resistors
float R2 = 7500; // 7.5 k
int value = 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(analogInput, INPUT);
}
void loop() {
Voltage();
}
void Voltage()
{
// read the value at analog input
value = analogRead(analogInput);
vout = (value * 5.0) / 1023.0; // see text
vin = vout / (R2/(R1+R2));
vin = vin + correctionfactor;
//Serial.print("INPUT V= ");
//Serial.println(vin);
delay(500);
lcd.setCursor(10,0);
lcd.print(vin);
if ( (vin > 0) && (vin < 150) )
{
lcd.setCursor(0,1);
lcd.print("Under Voltage");
}
if ( (vin >= 150) && (vin <= 190) )
{
lcd.setCursor(0,1);
lcd.print("Normal Voltage ");
}
if ( vin > 190 )
{
lcd.setCursor(0,1);
lcd.print("Over Voltage ");
}
}
To provide the best experiences, we use technologies like cookies to store and/or access device information. Consenting to these technologies will allow us to process data such as browsing behavior or unique IDs on this site. Not consenting or withdrawing consent, may adversely affect certain features and functions.