#define segment1 A1
#define segment2 A0
/* Program untuk seven segment Common Katoda */
byte digit[10] = {
//abcdefg dp
B11111100, // 0
B01100000, // 1
B11011010, // 2
B11110010, // 3
B01100110, // 4
B10110110, // 5
B10111110, // 6
B11100000, // 7
B11111110, // 8
B11110110, // 9
};
byte pinSegment[] = {A2,2,3,A5,A4,A3,5,4}; // pin yang digunakan untuk seven segment (pin dp,g,f,e,d,c,b,a)
long angka ;
void setup()
{
for(int i=0; i < 8; i++)
{
pinMode(pinSegment[i], OUTPUT);
}
pinMode(segment1,OUTPUT);
pinMode(segment2,OUTPUT);
}
void loop()
{
/* ---------------- kirim angka 5----------------------- */
digitalWrite(segment2,LOW); // matikan 7 segment 2
for ( byte segment = 0; segment < 8; segment++)
{
boolean Status = bitRead(digit[5],segment);
digitalWrite(pinSegment[segment],Status);
}
digitalWrite(segment1, HIGH); // hidupkan 7 segment 1
delay(5);
/* --------------- kirim angka 1 ------------------------*/
digitalWrite(segment1, LOW); // matikan 7 segment 1
for ( byte segment = 0; segment < 8; segment++)
{
boolean Status = bitRead(digit[1],segment);
digitalWrite(pinSegment[segment],Status);
}
digitalWrite(segment2,HIGH); // hidupkan 7 segment 2
delay(5);
}