0% found this document useful (0 votes)
11 views2 pages

#Include #Include: 0 0 0 0 27 16 2

Program
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
11 views2 pages

#Include #Include: 0 0 0 0 27 16 2

Program
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 2

int sensorValue0=0;

int sensorValue1=0;
int sensorValue2=0;
int sensorValue3=0;
#include <Wire.h>
#include <LiquidCrystal_I2C.h>
LiquidCrystal_I2C lcd(0x27, 16, 2);
void setup()
{
lcd.init();
lcd.backlight();
lcd.clear();
lcd.setCursor(0,0);
lcd.print("Automatic Source");
delay(200);
lcd.setCursor(0,1);
lcd.print("Selection");
delay(2000);
lcd.clear();
pinMode(4,OUTPUT); //solar
pinMode(5,OUTPUT); //Wind
pinMode(6,OUTPUT); //Battery
pinMode(7,OUTPUT); //Grid
}

void loop()
{
sensorValue0 = analogRead(A0); //Solar
delay(20);
sensorValue1 = analogRead(A1); //Wind
delay(20);
sensorValue2 = analogRead(A2); //Battery
delay(20);
if(sensorValue0 > 100) //Solar
{
digitalWrite(4,HIGH);
digitalWrite(5,LOW);
digitalWrite(6,LOW);
digitalWrite(7,LOW);
delay(100);
lcd.setCursor(0,0);
lcd.print("Source = Wind ");
}
else
{
if(sensorValue1 > 100)
{
digitalWrite(5,HIGH);
digitalWrite(4,LOW);
digitalWrite(6,LOW);
digitalWrite(7,LOW);
delay(100);
lcd.setCursor(0,0);
lcd.print("Source = Solar ");
}
else
{
if(sensorValue2 > 100)
{
digitalWrite(6,HIGH);
digitalWrite(4,LOW);
digitalWrite(5,LOW);
digitalWrite(7,LOW);
delay(100);
lcd.setCursor(0,0);
lcd.print("Source = Battery ");
}
else
{
if(sensorValue2 < 100)
{
digitalWrite(7,HIGH);
digitalWrite(4,LOW);
digitalWrite(5,LOW);
digitalWrite(6,LOW);
delay(100);
lcd.setCursor(0,0);
lcd.print("Source = Grid ");
}
}
}
}
}

You might also like