Demo entry 6351258

n

   

Submitted by anonymous on Mar 20, 2017 at 07:57
Language: C. Code size: 1.0 kB.

#include<reg52.h>
#include<intrins.h> 

#define uchar unsigned char 
#define uint unsigned int

void delayms (uint x)       //1ms delay
{    
	uint i,j;   
	for(i=x;i>0;i--)  
		for(j=110;j>0;j--); 
} 

unsigned char code digittab[][8]={
{0x1E,0x10,0x08,0x0C,0x04,0x02,0x1E,0x00},/*"Z"*/ 
{0x10,0x10,0x10,0x10,0x12,0x12,0x0C,0x00},/*"J"*/
{0x12,0x12,0x12,0x1E,0x12,0x12,0x12,0x00},/*"H"*/
};
uint timecount; 
unsigned char cnta; 
unsigned char cntb; 
void main(void) 
{  
  TMOD=0x01;  
  TH0=(65536-3000)/256; 
  TL0=(65536-3000)%256; 
  TR0=1; 
  ET0=1; 
  EA=1; 
  while(1) 
	{; 
	}
}  
void t0(void) interrupt 1 using 0 
{  
  TH0=(65536-2000)/256; 
  TL0=(65536-2000)%256;  
  P1=0XFF; 
  P0=~digittab[cntb][cnta]; 
  P1=~(0x01<<cnta); 
  cnta++; 
  if(cnta==8) 
    {  
      cnta=0; 
    }  
  timecount++;  
  if(timecount==500) 
    {  
      timecount=0; 
      cntb++;  
      if(cntb==3) 
        {  
          cntb=0; 
        } 
    } 
} 

This snippet took 0.01 seconds to highlight.

Back to the Entry List or Home.

Delete this entry (admin only).