Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- int menu = 0;
- bool editMenu = false;
- int maximaTempratura = 0;
- int temp;
- int botaoEsquerda;
- int botaoCima;
- int botaoDireita;
- int botaoOk;
- int botaoBaixo;
- int buttonState; // the current reading from the input pin
- int lastButtonState = LOW; // the previous reading from the input pin
- long lastDebounceTime = 0; // the last time the output pin was toggled
- long debounceDelay = 200; // the debounce time; increase if the output flickers
- // 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);
- void setup() {
- // set up the LCD's number of columns and rows:
- lcd.begin(16, 2);
- // Print a message to the LCD.
- lcd.print("hello, world!");
- // put your setup code here, to run once:
- Serial.begin(9600);
- pinMode(2, INPUT);
- pinMode(3, INPUT);
- pinMode(4, INPUT);
- pinMode(5, INPUT);
- digitalWrite(2, LOW);
- digitalWrite(3, LOW);
- digitalWrite(4, LOW);
- digitalWrite(5, LOW);
- Serial.println('Inicando projeto');
- }
- void loop() {
- botaoEsquerda = digitalRead(2);
- botaoCima = digitalRead(3);
- botaoDireita = digitalRead(4);
- botaoOk = digitalRead(5);
- if(!editMenu){
- // temp - analogREad(3)
- if(botaoEsquerda){
- delay(200);
- if(menu == 0) {
- menu = 3;
- } else {
- menu = menu - 1;
- }
- }
- if(botaoDireita){
- delay(200);
- if(menu == 3) {
- menu = 0;
- } else {
- menu = menu + 1;
- }
- }
- }
- temp = analogRead(A5);
- switch(menu){
- case 0:
- MostraMenu0();
- break;
- case 1:
- MostraMenu1();
- break;
- case 2:
- MostraMenu2();
- break;
- case 3:
- MostraMenu3();
- break;
- default:
- MostraMenuDefault();
- }
- }
- void MostraMenu0() {
- //lcd.setCursor(0, 1);
- //lcd.print(millis() / 1000);
- }
- void MostraMenu1() {
- //lcd.setCursor(0, 1);
- //lcd.print(maximaTempratura);
- Serial.println(1);
- if(botaoOk) {
- // reseta a hora
- editMenu = true;
- }
- if(botaoBaixo){
- editMenu = false;
- }
- if(editMenu) {
- if(botaoEsquerda) {
- maximaTempratura = maximaTempratura - 1;
- }
- if(botaoDireita) {
- maximaTempratura = maximaTempratura + 1;
- }
- }
- Serial.println(maximaTempratura);
- }
- void MostraMenu2() {
- Serial.println(2);
- }
- void MostraMenu3() {
- Serial.println(3);
- }
- void MostraMenuDefault(){
- Serial.println(4);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement