arduino TM1637 4 digit display how to enable colon?

2018-05-28 11:31 am
i'm making an extremely simple clock but i cant figure out how to light the colon.
heres my code:

#include <TM1637Display.h>
#define CLK 4 //can be any digital pin
#define DIO 5 //can be any digital pin
TM1637Display display(CLK, DIO);

int hours = 6; //set these to
int minutes = 40; //whatever time it is
bool am = false; //define if its am or pm
const int led = 6; //am/pm led indicator pin

void setup() {
}

void loop() {
display.setBrightness(1);
display.showNumberDec(hours * 100 + minutes, false, 4, 0);
minutes += 1;
if (minutes >= 60)
{
minutes = 0;
hours += 1;
}
if (hours >= 12)
{
hours = 1;
if (am == true)
{
am = false;
}
else
{
am = true;
}
}
if (am == true)
{
digitalWrite(led, HIGH);
}
else
{
digitalWrite(led, LOW);
}
delay(60000); //60 seconds
}
the following code works to enable the colon:

uint8_t segto;
int value = 1244;
segto = 0x80 | display.encodeDigit((value / 100)%10);
display.setSegments(&segto, 1, 1);
but i cant figure out how to change the number being displayed

回答 (1)

2018-05-28 1:28 pm
I'm guessing that your code displays "12:44", and you would change the number by changing the "value=" line.


收錄日期: 2021-05-01 22:06:52
原文連結 [永久失效]:
https://hk.answers.yahoo.com/question/index?qid=20180528033146AAAj5B8

檢視 Wayback Machine 備份