郭天祥十天学会单片机(例程)
- 1、下载文档前请自行甄别文档内容的完整性,平台不提供额外的编辑、内容补充、找答案等附加服务。
- 2、"仅部分预览"的文档,不可在线预览部分如存在完整性等问题,可反馈申请退款(可完整预览的文档不适用该条件!)。
- 3、如文档侵犯您的权益,请联系客服反馈,我们会尽快为您处理(人工客服工作时间:9:00-18:30)。
郭天祥十天学会单片机视频例程(部分) Lesson3_1-lesson3_4
#include
sbit dula=P2^6;
sbit wela=P2^7;
void main()
{
wela=1;
P0=0xc0;
wela=0;
dula=1;
P0=0x06;
dula=0;
while(1);
}
#include
#define uint unsigned int
#define uchar unsigned char
sbit dula=P2^6;
sbit wela=P2^7;
uchar num;
uchar code table[]={
0x3f,0x06,0x5b,0x4f,
0x66,0x6d,0x7d,0x07,
0x7f,0x6f,0x77,0x7c,
0x39,0x5e,0x79,0x71};
void delay(uint z);
void main()
{
wela=1;//11101010
P0=0xea;
wela=0;
while(1)
{
for(num=0;num<16;num++)
{
dula=1;
P0=table[num];
dula=0;
delay(1000);
}
}
}
void delay(uint z)
{
uint x,y;
for(x=z;x>0;x--)
for(y=110;y>0;y--);
}
#include
#define uint unsigned int
#define uchar unsigned char
sbit dula=P2^6;
sbit wela=P2^7;
sbit d1=P1^0;
uchar num;
uchar code table[]={
0x3f,0x06,0x5b,0x4f,
0x66,0x6d,0x7d,0x07,
0x7f,0x6f,0x77,0x7c,
0x39,0x5e,0x79,0x71};
void delay(uint z);
void main()
{
EA=1;//开总中断
EX0=1;//开外部中断0
//IT0=1;
TCON=0x01;
wela=1;//11101010
P0=0xea;
wela=0;
while(1)
{
for(num=0;num<16;num++)
{
d1=1;
dula=1;
P0=table[num];
dula=0;
delay(1000);
}
}
}
void delay(uint z)
{
uint x,y;
for(x=z;x>0;x--)
for(y=110;y>0;y--);
}
void exter0() interrupt 0
{
d1=0;
}
#include
#define uint unsigned int
#define uchar unsigned char
sbit dula=P2^6;
sbit wela=P2^7;
sbit d1=P1^0;
uchar num,num1;tt;
uchar code table[]={
0x3f,0x06,0x5b,0x4f,
0x66,0x6d,0x7d,0x07,
0x7f,0x6f,0x77,0x7c,
0x39,0x5e,0x79,0x71};
void delay(uint z);
void main()
{
num=0;
tt=0;
TMOD=0x11;//设置定时器0为工作方式1
TH0=(65536-10000)/256;
TL0=(65536-10000)%256;
TH1=(65536-20000)/256;
TL1=(65536-20000)%256;
// EA=1;//开总中断
ET0=1;//开定时器0中断
ET1=1;
TR0=1;//启动定时器0
TR1=1;
wela=1;//11101010
P0=0xea;
wela=0;
dula=1;
P0=0x3f;
dula=0;
while(1)
{
if(num1==25)
{
num1=0;
P1=~P1;
}
if(tt==100)
{
tt=0;
num++;
if(num==16)
num=0;
dula=1;
P0=table[num];
dula=0;
}
}
}
void delay(uint z)
{
uint x,y;
for(x=z;x>0;x--)
for(y=110;y>0;y--);
}
void time0() interrupt 1
{
TH0=(65536-10000)/256;
TL0=(65536-10000)%256;
tt++;
}
void time1() interrupt 3
{
TH1=(65536-20000)/256;
TL1=(65536-20000)%256;
num1++;
}
Lesson4_1-lesson4_3
#include
#include
#define uint unsigned int
#define uchar unsigned char
uchar temp,aa,num;
sbit dula=P2^6;
sbit wela=P2^7;
uchar code table[]={
0x3f,0x06,0x5b,0x4f,
0x66,0x6d,0x7d,0x07,
0x7f,0x6f,0x77,0x7c,
0x39,0x5e,0x79,0x71};
void delay(uint z);
void main()
{
num=0;
aa=0;
TMOD=0x01;
TH0=(65536-50000)/256;
TL0=(65536-50000)%256;
EA=1;
ET0=1;
TR0=1;
temp=0xfe;
P1=temp;
dula=1;
P0=table[0];
dula=0;
wela=1;
P0=0xc0;
wela=0;
while(1)
{
delay(1000);
temp=_crol_(temp,1);
P1=temp;
/* if(aa==40)
{
aa=0;
num++;
if(num==16)
num=0;
dula=1;
P0=table[num];
dula=0;
} */
}
}
void delay(uint z)
{
uint x,y;
for(x=z;x>0;x--)
for(y=110;y>0;y--);
}
void timer0() interrupt 1
{
TH0=(65536-50000)/256;
TL0=(65536-50000)%256;
aa++;
if(aa==40)
{
aa=0;
num++;
if(num==16)
num=0;
dula=1;
P0=table[num];
dula=0;
}
}
#include
#include
#define uint unsigned int
#define uchar unsigned char
uchar temp,aa,numdu,numwe;
sbit dula=P2^6;
sbit wela=P2^7;
uchar code table[]={
0x3f,0x06,0x5b,0x4f,
0x66,0x6d,0x7d,0x07,
0x7f,0x6f,0x77,0x7c,
0x39,0x5e,0x79,0x71};
uchar code tablewe[]={
0xfe,0xfd,0xfb,0xf7,0xef,0xdf};
//void delay(uint z);
void main()
{
numdu=0;
numwe=0;
aa=0;
TMOD=0x01;
TH0=(65536-5000)/256;
TL0=(65536-5000)%256;
EA=1;
ET0=1;
TR0=1;
while(1)
{
// delay(1000);
// temp=_crol_(temp,1);
// P1=temp;
if(aa==1)
{