من s0 و s1رو برای ثانیه شمار در مکان (0 ,0) و m0 و m1و رو برای دقیقه شماردر مکان(1,0) فرض کردم
کد:
#include <lpc21xx.h>
#include <stdio.h>
#include <delay.h>
//#include <lcd.h>
int S0 = 0;
int S1 = 0;
int MINUTE0 = 0;
int M1 = 0;
int MINUTE = 0;
int SECOND = 0;
int NUM;
int I;
void main(void)
{
char buffer[4];
lcd_init(20);
uint8_t p1[] = m0 m1;
uint8_t p2[] = s0 s1;
sprintf(p1," %i",s);
sprintf(p2," %i",s);
void main(void)
{
//pllInit(); // Set PLL to ×5
//vpbdivInit(); // Set VPB to 1
lcdInit();
lcdClear();
lcdGotoxy(0,0);
displayText(p1);
lcdGotoxy(0,1);
displayText(p2);
while(TRUE);
}
SECOND += 1;
if (SECOND == 60)
{
SECOND = 0;
MINUTE += 1;
}
NUM = MINUTE % 10;
M0 =Number (NUM);
NUM = MINUTE / 10;
MINUTE1 =Number (NUM);
NUM = SECOND % 10;
S0 = Number (NUM);
NUM = SECOND / 10;
S1 = Number (NUM);
T0IR = 0x00000001;
}
switch (I)
{
case 0:
NUM = M1;
break;
case 1:
NUM = M0;
break;
case 2:
NUM = S1;
break;
case 3:
NUM = S0;
break;
}