八个灯接在单片机的P1口(P0,P2,P3,P4都一样)while(1){ delay(你想要延时的时间);P1=0xff;delay(你想要延时的时间);P1=0;} 注意led最好加驱动,不然单片机会坏的。
用C啊,我想想:1、和硬件有点儿关系,这个你清楚么?2、假设LED连接到P1口吧。第一个灯接到P1.0。阴极接IO,阳极接5V。include <reg51.h> bit SecFlag;unsigned char mS;void Display(unsigned char num,unsigned char sec){ num%=8;P1=~(1<<num);while(sec--!=0){ TR0=1;while(...
uchar distab[]={0x3f,0x06,0x5b,0x4f,0x66,0x6d,0x7d,0x07,0x7f,0x6f,0x77,0x7c,0x39,0x5e,0x79,0x71,0x00}; //0到f uchar number;void t0isr() interrupt 1 { TH0=(65536-5000)/256;TL0=(65536-5000)%256;number++;if(number>1)number=0;switch(number){ case 0:P2=...
include <reg51.h> include <stdio.h> void timer0_ISR(void) interrupt 1 using 3 { P1 = ~P1;TL0 = 0XFF;TH0 = 0XFF;TF0 = 0;} void timer_init(void){ IE=0x82; //寮€镐讳腑鏂璄A锛屽厑璁稿畾镞跺櫒0涓柇ET0 TCON=0x00; //锅沧瀹氭椂...
。。。简单到离谱了,一楼还有脸说代做。。。细节你没说明,以下是按下开关不放时,两个灯一起闪,1秒亮1秒暗。开关松开就停止闪烁。include <reg52.h> sbit d1=P0^0;sbit d2=P0^1;sbit k1=P3^0;void delay(int x){ char y;while(x--)for(y=0;y<120;y++);} void main(){ w...
程序如下: 绝对没有错 LED灯的一端接P1口的各各引脚,另一端接地。同时在P1口的每个管脚上加1K的上拉电阻,电阻另一端连接至+5V即可 ORG 0000H AJMP START ORG 0030H START:MOV SP,#07H MOV P1,#00H MOV A,#0AAH LOOP:CPL A MOV P1,A ACALL DELAY AJMP LOOP DELAY:MOV R0,#50...
while(1){recy=0xfe;for(k=1;k<=8;k++){ P1=recy;Delay(50000);recy=recy<<1;} }
P1=j;//将移位后的值赋给P1口,这样就可以显示出来了。} } / 其实可以不用变量J,改后如下:include <reg51.h> include <intrins.h> unsigned char a,b,k;void delay10ms(){ for(a=100;a>0;a--)for(b=225;b>0;b--);} void main(){ k=0xfe;while(1){ delay10ms();delay...
一种是采用8行8列组成的按键就可以了,实际上是16个开关,但可以实现64个按键。具体的看看网上的4*4键盘是什么原理。基础要自己想。第二种是采用8255或8155扩展,具体的要自己去看去学。
void timer0() interrupt 1 using 2 { TH0=0xed ;TL0=0xff ;ttt++;//if(ttt>=1000){ ttt = 0;timer1s_flag++;P1 = 0;//P0 = ~col_s[col];P0 = col;P1 = Bmp510[count*6+col];col++;col %= 6;} }这个程序时实现8*8点阵led显示的 0~9 循环显示。间隔500ms ...