I LCD 스크린의 첫 번째 줄에 시계를 표시해야이 코드 및 두 번째 줄의 텍스트에 "Hello World"가 다음아두 이노의 LCD 시계
#include <LiquidCrystal.h>
int x=0;
int a=0;
int y=0;
int z=0;
int initialHours = 14;//set this to whatever
int initialMins = 37;
int initialSecs = 45 + 11;
int secspassed()
{
x = initialHours*3600;
x = x+(initialMins*60);
x = x+initialSecs;
x = x+(millis()/1000);
return x;
}
int hours()
{
y = secspassed();
y = y/3600;
y = y%24;
return y;
}
int mins()
{
z = secspassed();
z = z/60;
z = z%60;
return z;
}
int secs()
{
a = secspassed();
a = a%60;
return a;
}
LiquidCrystal lcd(8, 9, 4, 5, 6, 7);
void setup(){
lcd.print("load...");
delay(1000);
lcd.begin(16, 2);
lcd.setCursor(0, 1);
lcd.print("Hello world");
}
void loop(){
digitalClockDisplay();
}
void printDigits(byte digits){
if(digits < 10)
lcd.print('0');
lcd.print(digits);
}
char sep()
{
x = millis()/1000;
if(x%2==0)
{
lcd.print(":");
}
else {
lcd.print(" ");
}
}
void digitalClockDisplay(){
lcd.setCursor(0,0);
printDigits(
hours());
sep();
printDigits(mins());
sep();
printDigits(secs());
}
대신 인쇄를
12:35:15
Hello World
는이 대신 인쇄 :
253:255:243
Hello World
이유는 무엇입니까?
시간 라이브러리 BTW를 사용하고 싶지 않습니다.
그냥 전화하면 millis()가 출력합니까? – CBredlow
코드를 업로드 한 이후의 시간 (밀리 초)입니다. – Cinder