单片机入门必学的一些课程
#include <Reg52.h > sbit key=P3^1;//jian char code table[]={0x3f,0x06,0x5b,0x4f,0x66,0x6d,0x7d,0x07,0x7f,0x6f,0x77,0x7c,0x39,0x5e,0x79,0x71}; //0-9 int n = 0; void disp_7seg(int num); void delay(int i) { int x,y; for(x=i;x>0;x--) for(y=255;y>0;y--); } void main() { while(1) { disp_7seg(n); if(key==0) { delay(20); if(key==0) { n++; } while (key==0); } } } void disp_7seg(int num) { P2 = 0xFE;//1111 1110; P0 = table[num/1000]; delay(2); P2 = 0xFD;//1111 1101; P0 = table[num%1000/100]; delay(2); P2 = 0xFB;//1111 1011; P0 = table[num%100/10]; delay(2); P2 = 0xF7;//1111 0111; P0 = table[num%10]; delay(2); } ============================找指导老师布置任务吧==============================