#include <LiquidCrystal.h>
#define RS 7
#define E 6
#define D4 12
#define D5 10
#define D6 9
#define D7 8
#define LED 4
#define ch01 1
#define ch02 2
LiquidCrystal lcd(RS,E,D4,D5,D6,D7);
int valor = 0;
float tensao = 0;
char z = 255;
void setup()
{
Serial.begin(9600);
lcd.begin(16,2);
pinMode(A0, INPUT);
pinMode(LED, OUTPUT);
pinMode(ch01, INPUT);
pinMode(ch02, INPUT);
lcd.print(z);
}
void loop()
{
if( digitalRead(ch01) == LOW )
{
lcd.print("SISTEMA LIGADO ");
delay(1000);
lcd.clear();
lcd.print("LOADING ");
lcd.setCursor(0,1);
lcd.print(".");
delay(1000);
lcd.print(".");
delay(1000);
lcd.print(".");
delay(1000);
lcd.print(".");
delay(1000);
lcd.print(".");
delay(1000);
lcd.print(".");
delay(1000);
lcd.print(".");
delay(1000);
lcd.print(".");
delay(1000);
lcd.print(".");
delay(1000);
lcd.print(".");
delay(1000);
lcd.print(".");
delay(1000);
lcd.print(".");
delay(1000);
lcd.print(".");
delay(1000);
lcd.print(".");
delay(1000);
lcd.clear();
lcd.print("Valor = ");
lcd.setCursor(0,1);
lcd.print("Tensao =");
while(1)
{
lcd.setCursor(10,0);
lcd.print(valor);
lcd.print(" ");
lcd.setCursor(10,1);
lcd.print(tensao);
lcd.print(" ");
lcd.print("V");
valor = analogRead(A0);
tensao = valor * 0.00488759;
delay(1000);
Serial.print("Valor = ");
Serial.println(valor);
Serial.print("Tensão = ");
Serial.print(tensao);
Serial.println(" V");
delay(1000);
if(tensao >= 2.5)
{
digitalWrite(LED, HIGH);
}
else
{
digitalWrite(LED, LOW);
}
if(digitalRead(ch02) == LOW)
{
digitalWrite(LED, LOW);
lcd.clear();
break;
}
}
}
}
/*// include the LiquidCrystal.h library
#include <LiquidCrystal.h>
// Double slash for adding single line comments
const int rs = 7; // Pin 7 on Arduino to pin 4 (RS) on LCD
const int en = 6; // Pin 6 on Arduino to pin 6 (E) on LCD
const int d4 = 12; // Pin 12 on Arduino to pin 11 (D4) on LCD
const int d5 = 10; // Pin 10 on Arduino to pin 12 (D5) on LCD
const int d6 = 9; // Pin 9 on Arduino to pin 13 (D6) on LCD
const int d7 = 8; // Pin 8 on Arduino to pin 14 (D7) on LCD
LiquidCrystal lcd(rs, en, d4, d5, d6, d7);
void setup() {
// Set up the LCD's number of columns and rows:
lcd.begin(16, 2);
// Print Hello World! to the LCD.
lcd.print("Hello World!");
}
void loop() {
}*/