byte seven_seg_digits[10][8] = { //
//a,b,c,d,e,f,g,h
{1, 1, 1, 1, 1, 1, 1, 0}, //0
{0, 1, 1, 0, 0, 0, 0, 0}, //1
{1, 1, 0, 1, 1, 0, 1, 0}, //2
{1, 1, 1, 1, 0, 0, 1, 0}, //3
{0, 1, 1, 0, 0, 1, 1, 0}, //4
{1, 0, 1, 1, 0, 1, 1, 0}, //5
{1, 0, 1, 1, 1, 1, 1, 0}, //6
{1, 1, 1, 0, 0, 1, 0, 0}, //7
{1, 1, 1, 1, 1, 1, 1, 0}, //8
{1, 1, 1, 1, 0, 1, 1, 0}, //9
};
int Switch1_Pin = A1;
int Switch2_Pin = A2;
int Switch3_Pin = A3;
int Switch4_Pin = A4;
int Switch5_Pin = A5;
int Fnd_a = 7;
int Fnd_b = 6;
int Fnd_c = 5;
int Fnd_d = 4;
int Fnd_e = 3;
int Fnd_f = 2;
int Fnd_g = 1;
int Fnd_dot = 0;
void setup()
// put your setup code here, to run once:
{
pinMode(Fnd_a, OUTPUT);
pinMode(Fnd_b, OUTPUT);
pinMode(Fnd_c, OUTPUT);
pinMode(Fnd_d, OUTPUT);
pinMode(Fnd_e, OUTPUT);
pinMode(Fnd_f, OUTPUT);
pinMode(Fnd_g, OUTPUT);
pinMode(Fnd_dot, OUTPUT);
writeDot(0);
pinMode(Switch1_Pin, INPUT);
pinMode(Switch2_Pin, INPUT);
pinMode(Switch3_Pin, INPUT);
pinMode(Switch4_Pin, INPUT);
pinMode(Switch5_Pin, INPUT);
}
void writeDot(byte dot)
// put your main code here, to run repeatedly:
{
digitalWrite(7, dot);
}
void NumberDisplay(byte num)
{
int j;
for (j = 7; j >= 0; j--)
{
digitalWrite(j, seven_seg_digits[num][j]);
}
}
void loop()
{
if (digitalRead(Switch1_Pin) == LOW)
{
NumberDisplay(1);
}
else if (digitalRead(Switch2_Pin) == LOW)
{
NumberDisplay(3);
}
else if (digitalRead(Switch3_Pin) == LOW)
{
NumberDisplay(5);
}
else if (digitalRead(Switch4_Pin) == LOW)
{
NumberDisplay(7);
}
else if (digitalRead(Switch5_Pin) == LOW)
{
NumberDisplay(9);
}
else
{
NumberDisplay(0);
}
}
해결 방법좀 알려주세요 부탁드립니다
|