BASIC4MCU | 질문게시판 | 아두이노 LCD 시계
페이지 정보
작성자 dentist22 작성일2022-06-16 21:35 조회278회 댓글0건
https://www.basic4mcu.com/bbs/board.php?bo_table=gac&wr_id=20656
본문
시계의 시간 설정hours minutes seconds의 숫자를 증가시키기 위해서 버튼을 누르면 시간이 증가 감소되어야 하는데 버튼을 눌러도 아무일도 일어나지 않습니다.맨 오른쪽 버튼은 다른 버튼들을 눌렀을 때 시간의 증가감소를 설정하는 버튼입니다.혹시 up_botton이나 down_button의 함수 선언이 잘못된건지 어떤게 문제점인지 궁금합니다.#include <LiquidCrystal_I2C.h>#include <Wire.h>LiquidCrystal_I2C lcd(0x20, 16, 2);void setup() {pinMode(11, INPUT); pinMode(10, INPUT);pinMode(9, INPUT); pinMode(8, INPUT);lcd.init();lcd.backlight();}unsigned int seconds = 0;unsigned int minutes = 0;unsigned int hours = 0;int toggle=1;int labutton=LOW, prbutton;void botton_up(){if(11==HIGH)hours++;if(10==HIGH)minutes++;if(9==HIGH)seconds++;}void botton_down(void){if(11==HIGH)hours--;if(10==HIGH)minutes--;if(9==HIGH)seconds--;}void loop() {{unsigned long t = millis();if(t%1000 == 0) {seconds++;if (seconds==60)minutes++;if (seconds==60)seconds=0;if (minutes==60)hours++;if (minutes==60)minutes=0;if (hours==13)hours=0;lcd.setCursor(0,1);lcd.print(" "+String(hours)+"h"+String(minutes)+"m" +String(seconds) + "s");lcd.print(" ");presentbutton = digitalRead(8);if(presentbutton != lastbutton){if(presentbutton==LOW) toggle=toggle*-1;}if(toggle==1) botton_up();else botton_down();lastbutton = presentbutton;delay(300);}}}
댓글 0
조회수 278등록된 댓글이 없습니다.