#define key2 A1
#define key3 A2
byte seg7[]={9,8,7,6,5,4,3};
int i,j;
int mode=-1;
void setup()
{
// put your setup code here, to run once:
for(j=0;j<7;j++)
{
pinMode(seg7[j],OUTPUT);
}
pinMode(key1,INPUT);
pinMode(key2,INPUT);
pinMode(key3,INPUT);
}
void loop()
{
// put your main code here, to run repeatedly:
if(digitalRead(key1)==0 && mode !=1) {mode=1;outport(0x71);}
if(digitalRead(key2)==0 && mode !=2) {mode=2;outport(0x6D);}
if(digitalRead(key3)==0 && mode !=3) {mode=3;outport(0x7C);}
}
void outport(byte data)
{
for(i=0;i<7;i++)
{
digitalWrite(seg7[i],bitRead(data,i));
}
}
沒有留言:
張貼留言