/*
LiquidCrystal Library - Hello World
Demonstrates the use a 16x2 LCD display. The LiquidCrystal
library works with all LCD displays that are compatible with the
Hitachi HD44780 driver. There are many of them out there, and you
can usually tell them by the 16-pin interface.
This sketch prints "Hello World!" to the LCD
and shows the time.
The circuit:
* LCD RS pin to digital pin 12
* LCD Enable pin to digital pin 11
* LCD D4 pin to digital pin 5
* LCD D5 pin to digital pin 4
* LCD D6 pin to digital pin 3
* LCD D7 pin to digital pin 2
* LCD R/W pin to ground
* LCD VSS pin to ground
* LCD VCC pin to 5V
* 10K resistor:if (digitalRead(b_set) == 0 && numero_menu ==0) {
numero_menu =1;
ventilador1;}
* ends to +5V and ground
* wiper to LCD VO pin (pin 3)
Library originally added 18 Apr 2008
by David A. Mellis
library modified 5 Jul 2009
by Limor Fried (http://www.ladyada.net)
example added 9 Jul 2009
by Tom Igoe
modified 22 Nov 2010
by Tom Igoe
This example code is in the public domain.
http://www.arduino.cc/en/Tutorial/LiquidCrystal
*/
// include the library code:
#include <LiquidCrystal.h>
// initialize the library with the numbers of the interface pins
LiquidCrystal lcd(12, 11, 5, 4, 3, 2);
const int LM35 = A0;
float temp;
int up = 18;
int ok = 17;
int down = 16;
int b_set = 13;
int numero_menu =0;
int numero_titulo=1;
byte v1t = 25;
byte v2t = 26;
byte v3t = 27;
byte neb = 28;
byte aquec = 30;
byte rele1 =7;
byte rele2 =8;
byte rele3 =9;
byte rele4 =10;
byte rele5 =6;
byte enc_ok = 19;
byte enc_c =20;
byte enc_d =21;
// icone galinha
byte customChar[] = {
B00000,
B01000,
B11001,
B01111,
B01111,
B00110,
B00100,
B01010
};
// V1
byte v1[] = {
B10100,
B10100,
B01000,
B00010,
B00110,
B00010,
B00010,
B00010
};
byte v2[] = {
B10100,
B10100,
B01000,
B00111,
B00001,
B00111,
B00100,
B00111
};
byte v3[] = {
B10100,
B10100,
B01000,
B00111,
B00001,
B00011,
B00001,
B00111
};
byte nebul[] = {
B00100,
B01110,
B10010,
B00101,
B10010,
B01001,
B10010,
B01001
};
byte aquece[] = {
B00010,
B00010,
B00010,
B11111,
B10001,
B10101,
B10001,
B11111
};
byte celsius[] = {
B10000,
B00111,
B01000,
B01000,
B01000,
B01000,
B00111,
B00000
};
//Variável para os títulos das páginas.
char* Titulo_Menu[] = {
"Jarvis",
"Ventilador-1:",
"Ventilador-2:",
"Ventilador-3:",
"Nebulizacao:",
"Aquecedor:"};
void setup()
{
// set up the LCD's number of columns and rows:
lcd.begin(16, 2);
lcd.createChar(0, customChar);
lcd.createChar(1, v1);
lcd.createChar(2, v2);
lcd.createChar(3, v3);
lcd.createChar(4, nebul);
lcd.createChar(5, aquece);
lcd.createChar(6, celsius);
pinMode(up, INPUT_PULLUP);
pinMode(ok, INPUT_PULLUP);
pinMode(down, INPUT_PULLUP);
pinMode(b_set,INPUT_PULLUP);
pinMode(enc_ok,INPUT_PULLUP);
pinMode(enc_c,INPUT_PULLUP);
pinMode(enc_d,INPUT_PULLUP);
pinMode(rele1, OUTPUT);
pinMode(rele2, OUTPUT);
pinMode(rele3, OUTPUT);
pinMode(rele4, OUTPUT);
pinMode(rele5, OUTPUT);
Serial.begin(9600);
}
void loop()
{
principal();
ventilador1();
ventilador2();
ventilador3();
nebulizador();
aquecedor();
Serial.print( digitalRead(enc_c));
Serial.println(digitalRead(enc_d));
delay(250);
}
void principal()
{
temp=(float(analogRead(LM35))/20);
lcd.clear();
lcd.noBlink();
if (temp >= v1t && temp <= 200) { digitalWrite(rele1, HIGH);lcd.setCursor(0, 1);
lcd.write(byte(1));}
else {digitalWrite(rele1, LOW);lcd.setCursor(0, 1);
lcd.print("_");}
if (temp >= v2t && temp <= 200) { digitalWrite(rele2, HIGH);lcd.setCursor(2, 1);
lcd.write(byte(2));}
else {digitalWrite(rele2, LOW);lcd.setCursor(2, 1);
lcd.print("_");}
if (temp >= v3t && temp <= 200) { digitalWrite(rele3, HIGH); lcd.setCursor(4, 1);
lcd.write(byte(3));}
else {digitalWrite(rele3, LOW); lcd.setCursor(4, 1);
lcd.print("_");}
if (temp >= neb && temp <= 200) { digitalWrite(rele4, HIGH); lcd.setCursor(6, 1);
lcd.write(byte(4));}
else {digitalWrite(rele4, LOW); lcd.setCursor(6, 1);
lcd.print("_");}
if (temp <= aquec && temp >= 0) { digitalWrite(rele5, HIGH); lcd.setCursor(9, 1);
lcd.write(byte(5));}
else {digitalWrite(rele5, LOW); lcd.setCursor(9, 1);
lcd.print("_");}
lcd.setCursor(15,0);
//lcd.print(">");
lcd.write(byte(6));
lcd.setCursor(0,0);
lcd.print(Titulo_Menu [0]);
lcd.setCursor(10,0);
lcd.print(temp);
delay(250);
if (digitalRead(b_set) == 0 && numero_menu ==0) {
numero_menu =1;
ventilador1();}
if (digitalRead(enc_ok) == 0 && numero_menu ==0) {
numero_menu =1;
ventilador1();}
}
void ventilador1()
{
while (numero_menu ==1)
{
lcd.clear();
lcd.setCursor(0,0);
lcd.print(Titulo_Menu [1]);
lcd.setCursor(0,1);
lcd.print("Ajuste:");
lcd.blink();
lcd.setCursor(9,1);
lcd.print(v1t);// temp de ventilador 1
delay(250);
if (digitalRead(up) ==0)
{ v1t = 1+v1t;}
if (digitalRead(down) ==0)
{ v1t = v1t-1;}
if ( numero_menu==1 && digitalRead(ok) ==0)
{ numero_menu = 2; ventilador2();}
if ( numero_menu > 0 && digitalRead(b_set) ==0)
{ numero_menu = 0; principal();}
}
}
void ventilador2()
{
while (numero_menu ==2)
{
lcd.clear();
lcd.setCursor(0,0);
lcd.print(Titulo_Menu [2]);
lcd.setCursor(0,1);
lcd.print("Ajuste:");
lcd.blink();
lcd.setCursor(9,1);
lcd.print(v2t);// temp de ventilador 2
delay(250);
if (digitalRead(up) ==0)
{ v2t = 1+v2t;}
if (digitalRead(down) ==0)
{ v2t = v2t-1;}
if ( numero_menu==2 && digitalRead(ok) ==0)
{ numero_menu = 3; ventilador3();}
if ( numero_menu > 0 && digitalRead(b_set) ==0)
{ numero_menu = 0; }
}
}
void ventilador3()
{
while (numero_menu ==3)
{
lcd.clear();
lcd.setCursor(0,0);
lcd.print(Titulo_Menu [3]);
lcd.setCursor(0,1);
lcd.print("Ajuste:");
lcd.blink();
lcd.setCursor(9,1);
lcd.print(v3t);// temp de ventilador 3
delay(250);
if (digitalRead(up) ==0)
{ v3t = 1+v3t;}
if (digitalRead(down) ==0)
{ v3t = v3t-1;}
if ( numero_menu==3 && digitalRead(ok) ==0)
{ numero_menu = 4; nebulizador();}
if ( numero_menu > 0 && digitalRead(b_set) ==0)
{ numero_menu = 0; }
}
}
void nebulizador()
{
while (numero_menu ==4)
{
lcd.clear();
lcd.setCursor(0,0);
lcd.print(Titulo_Menu [4]);
lcd.setCursor(0,1);
lcd.print("Ajuste:");
lcd.blink();
lcd.setCursor(9,1);
lcd.print(neb);// temp de nebulizador 1
delay(250);
if (digitalRead(up) ==0)
{ neb = 1+neb;}
if (digitalRead(down) ==0)
{ neb = neb-1;}
if ( numero_menu==4 && digitalRead(ok) ==0)
{ numero_menu = 5; aquecedor();}
if ( numero_menu > 0 && digitalRead(b_set) ==0)
{ numero_menu = 0;principal(); }
}
}
void aquecedor()
{
while (numero_menu ==5)
{
lcd.clear();
lcd.setCursor(0,0);
lcd.print(Titulo_Menu [5]);
lcd.setCursor(0,1);
lcd.print("Ajuste:");
lcd.blink();
lcd.setCursor(9,1);
lcd.print(aquec);// temp de Aquecedor 1
delay(250);
if (digitalRead(up) ==0)
{ aquec = 1+aquec;}
if (digitalRead(down) ==0)
{ aquec = aquec-1;}
if ( numero_menu==5 && digitalRead(ok) ==0)
{ numero_menu = 1; ventilador1();}
if ( numero_menu > 0 && digitalRead(b_set) ==0)
{ numero_menu = 0; }
}
}