[qq]896795262[/qq]
- #include <STC15F2K60S2.h>
- #define uint unsigned int
- #define uchar unsigned char
- #define ulong unsigned long
- uchar code seg[]={0x3f,0x06,0x5b,0x4f,0x66,0x6d,0x7d,0x07,0x7f,0x6f};
- sbit key1=P0^0;
- bit duan,chang;
- #define LED1 P1
- uint n;
- void delayms(uint ms){
- uint i,j;
- for(i=ms;i>0;i--)
- for(j=110;j>0;j--);
- }
- void main(){
- P1M0=0XFF;
- P1M1=0X00;
- n=0;
-
- while(1){
- if (key1==0){
- delayms(800);
- if(key1==0){
- duan=1;
- chang=0;
- delayms(3000);
- if(key1==0){
- chang=1;
- duan=0;
- n=1;
- }
- while(!key1);
- }
- }
- if (duan){
- duan=0;
- LED1=seg[n];
- while(!key1);
- n++;
- if(n>9)
- n=0;
- }
- if(chang){
- chang=0;
- LED1=seg[0];
-
- }
- }
- }
-
复制代码
|