#include "delay.h"
#include <intrins.h>
#define LEDPROT P0
/*第一种流水灯
unsigned char leddate[8] = {0xfe,0xfd,0xfb,0xf7,0xef,0xdf,0xbf,0x7f};
void main()
{
unsigned char i=0;
while(1)
{
LEDPROT = leddate[i];
i++;
if(8 == i)
{
i=0;
}
delay_ms(20);
}
}
*/
/*void main()
{
LEDPROT = 0xfe;
while(1)
{
LEDPROT = _crol_(LEDPROT,1);
delay_s(1);
}
}
*/
//???????
unsigned char leddate[7] = {0x7e,0xbd,0xdb,0xe7,0xdb,0xbd,0x7e};
void main()
{
unsigned char i = 0;
while(1)
{
LEDPROT = leddate[i];
i++;
if(7 == i)
{
i = 0;
}
delay_ms(50);
}
}
声音
#include <reg52.h>
#include "delay.h"
#define LEDPROT P1
sbit BEEP=P0^5;
unsigned char leddata[10]={0xc0,0xf9,0xa4,0xb0,0x99,0x92,0x82,0xf8,0x80,0x90};
void main()
{
unsigned char i;
unsigned char j=9;
while(1)
{
if(j==0)
{
LEDPROT=0xc0;
for(i=0;i<100;i++)
{
BEEP=~BEEP;
delay_ms(1);
}
}
else
{
LEDPROT=leddata[j];
j--;
for(i=0;i<100;i++)
{
BEEP=~BEEP;
delay_ms(1);
}
delay_s(1);
}
}
}