问题描述
这是我的诺基亚 5110 lcd arduino 时钟项目。我试图使字体更小,setTextSize(1),仅在显示的第三行的秒数内。我可以更改所有内容的字体大小,但不是特别秒。任何事情都会有很大帮助,因为我对arduino很陌生。感谢您的时间!
//Programa : Teste display Nokia 5110 usando biblioteca Adafruit
//Autor : VINICIUS LOPES
#include <Adafruit_GFX.h>
#include <Adafruit_PCD8544.h>
// pin 3 - Serial clock out (SCLK)
// pin 4 - Serial date out (DIN)
// pin 5 - date/Command select (D/C)
// pin 6 - LCD chip select (CS/CE)
// pin 7 - LCD reset (RST)
Adafruit_PCD8544 display = Adafruit_PCD8544(3,4,5,6,7);
int second,minute,hour,day,mounth,year;
unsigned long UtlTime;
void setup() {
pinMode(2,OUTPUT);
UtlTime=0;
minute=30;
hour=6;
day=9;
mounth=5;
year=21;
Serial.begin(9600);
display.begin();
display.setContrast(80); // Adjust the display contrast
display.cleardisplay(); //Apaga o buffer e o display
display.setTextSize(2); //Seta o tamanho do texto
display.setTextColor(BLACK); //Seta a cor do texto
display.print("Date \n & \nTime ");
display.setCursor(0,10);
display.display();
delay (5000);
//Configura o hour
display.cleardisplay();
display.setCursor(0,0);
display.print("hour:");
display.display();
Serial.print("\nin between hour:");
while(hour==0) {
if (Serial.available() > 0)
{
hour= Serial.parseInt();
}
}
display.print(hour);
display.display();
delay(1000);
//Configura a minute
display.cleardisplay();
display.setCursor(0,0);
display.print("minute:");
display.display();
Serial.print("\nin between minute:");
while(hour==0)
{
if (Serial.available() > 0)
{
minute= Serial.parseInt();
}
}
display.print(minute);
display.display();
delay(1000);
//Configura o month
display.cleardisplay();
display.setCursor(0,0);
display.print("month:");
display.display();
Serial.print("\nin between month:");
while(mounth==0)
{
if (Serial.available() > 0)
{
day= Serial.parseInt();
}
}
display.print(mounth);
display.display();
delay(1000);
//Configura o mês
display.cleardisplay();
display.setCursor(0,0);
display.print("day:");
display.display();
Serial.print("\nin between day:");
while(day==0)
{
if (Serial.available() > 0)
{
day= Serial.parseInt();
}
}
display.print(day);
display.display();
delay(1000);
//Configura o year
display.cleardisplay();
display.setCursor(0,0);
display.print("year:");
display.display();
Serial.print("\nin between year:");
while(year==0)
{
if (Serial.available() > 0)
{
year= Serial.parseInt();
}
}
display.print(year);
display.display();
delay(1000);
display.cleardisplay();
}
void loop()
{
if(millis()-UtlTime<0)
{
UtlTime=millis();
}
else
{
second=int((millis()-UtlTime)/1000);
}
if(second>59)
{
second=0;
minute++;
UtlTime=millis();
if(minute>59)
{
hour++;
minute=0;
if(hour>23)
{
day++;
hour=0;
if(mounth==1||mounth==3||mounth==5||mounth==7||mounth==8||mounth==10||mounth==12)
{
if(day>31)
{
day=1;
mounth++;
if(mounth>12)
{
year++;
mounth=1;
}
}
}
else if(mounth==2)
{
if(year%400==0)
{
if(day>29)
{
day=1;
mounth++;
}
}
else if((year%4==0)&&(year%100!=0))
{
if(day>29)
{
day=1;
mounth++;
}
}
else
{
if(day>28)
{
day=1;
mounth++;
}
}
}
else
{
if(day>30)
{
day=1;
mounth++;
}
}
}
}
}
display.cleardisplay();
delay(1000);
Serial.print(mounth);
Serial.print("/");
Serial.print(day);
Serial.print("/");
Serial.print(year);
Serial.println();
display.setCursor(0,0);
display.print(" ");
display.print(mounth);
display.print("/");
display.print(day);
display.print("/");
display.print(year);
display.display();
Serial.print(hour);
Serial.print(":");
Serial.print(minute);
Serial.print(":");
Serial.print(second);
Serial.print("\n");
Serial.println();
display.setCursor(0,16);
display.print(" ");
display.print(hour);
display.print(":");
display.print(minute);
display.print("\n -");
display.print(second);
display.print("-");
display.display();
char tecla;
tecla = Serial.read();
if(tecla=='1'){
digitalWrite(2,LOW);
}
if(tecla=='2'){
digitalWrite(2,HIGH);
}
}
解决方法
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)