郭天祥视频教程完整C程序文件
- 1、下载文档前请自行甄别文档内容的完整性,平台不提供额外的编辑、内容补充、找答案等附加服务。
- 2、"仅部分预览"的文档,不可在线预览部分如存在完整性等问题,可反馈申请退款(可完整预览的文档不适用该条件!)。
- 3、如文档侵犯您的权益,请联系客服反馈,我们会尽快为您处理(人工客服工作时间:9:00-18:30)。
Lesson1
1
#include
sbit D2=P1^2;
unsigned int a;
void main()
{
D2=0;
/* for(a=0;a<=10000;a++){}; D2=1;
for(a=0;a<=10000;a++){};*/ }
2
#include
void main()
{
P1=0xfd;
}
lesson2
1
#include
sbit p1_1=P1^0
unsigned int a
void main()
{
while(1)
{
a=51000;
p1_1=0;
while(a--);
a=51000;
while(a--);
p1_1=1;
a=51000;
while(a--);
a=51000;
while(a--);
}
}
2
#include
#define uint unsigned int
#define uchar unsigned char sbit D1=P1^0;
//void delay();
void delay(uint);
void main()
{
while(1)
{
D1=0;
delay(100);
D1=1;
delay(100);
}
}
/*
void delay()
{
uint x,y;
for(x=100;x>0;x--) for(y=600;y>0;y--); }*/
void delay(uint z) {
uint x;
uchar y;
for(x=z;x>0;x--) for(y=20;y>0;y--); }
lesson3
1
#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);
}
2 #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--);
}
3
#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;
}
4
#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;