Demo entry 6349856

homework

   

Submitted by jiahan zhang on Feb 28, 2017 at 14:50
Language: C. Code size: 832 Bytes.

#include<reg52.h>
void delay(int);
int count=0; 
int res;
void main()
{
   TMOD=0x01;
   TH0=0x3C;
   TL0=0x0B0;
   EX0=1;
   IT0=1;
   EA=1;
   ET0=1;
   TR0=1;
   P2=0xFF;
   while(1)
   {
      
   }
}

void delay(int x)
{
   int i,j;
   for(i=x;i>0l;i--)
      for(j=110;j>0;j--);
}

void int0() interrupt 0
{
   TR0=~TR0;
   
}

void int1() interrupt 1
{
   TH0=0x3C;
   TL0=0x0B0;
   
   count++;
   if(count==20){
      P2=0x24;
   }
   else if(count==40){
      P2=0x00;
   }
   else if(count==60){
      P2=0x19;
   }
   else if(count==80){
      P2=0x19;
   }
   else if(count==100){
      P2=0x30;
   }
   else if(count==120){
      P2=0x24;
   }
   else if(count==140){
      P2=0x10;
   }
   else if(count==160){
      P2=0x10;
      count=0;
   }
   
}

This snippet took 0.00 seconds to highlight.

Back to the Entry List or Home.

Delete this entry (admin only).