想做个矩阵键盘控制流水灯模式
#include <REGX52.H>
#include "Delay.h"
#include "Matrixkey.h"
#include <INTRINS.H>
#include "Timer_0.h"
unsigned char a,led;
static unsigned char count;
void main()
{
Timer_0_Init;
P2=0xFE;
led=1;
while(1)
{a=Matrixkey();
if(a=1){led++;}
if(a=2){led--;}
if(led>=2)
led=1;
if(led<=0)
led=1;
if(count>=500)
switch(led)
{case 2:P2=_crol_(P2,1);count=0;break; case 0:P2=_cror_(P2,1);count=0;break;}}}}
}
void Timer_0_Routine()
interrupt 1
{TL0 = 0x66;
TH0 = 0xFC;
count++;}
#include <REGX52.H>
#include "Delay.h"
#include "Matrixkey.h"
#include <INTRINS.H>
#include "Timer_0.h"
unsigned char a,led;
static unsigned char count;
void main()
{
Timer_0_Init;
P2=0xFE;
led=1;
while(1)
{a=Matrixkey();
if(a=1){led++;}
if(a=2){led--;}
if(led>=2)
led=1;
if(led<=0)
led=1;
if(count>=500)
switch(led)
{case 2:P2=_crol_(P2,1);count=0;break; case 0:P2=_cror_(P2,1);count=0;break;}}}}
}
void Timer_0_Routine()
interrupt 1
{TL0 = 0x66;
TH0 = 0xFC;
count++;}