2. Tulis program untuk arduino di software Arduino IDE.
3. Compile program tadi, lalu upload ke dalam arduino.
4. Setelah program selesai di upload, jalankan simulasi rangkaian pada proteus.
Flowchart :
Listing Program :
#define a 6
#define b 7
#define c 8
#define d 9
#define e 10
#define f 11
#define g 12
#define dp 13
#define Dsw1 A0
#define Dsw2 A1
#define Dsw3 A2
#define Dsw4 A3
bool sw1,sw2,sw3,sw4;
int segments[] = {a, b, c, d, e, f, g};
byte digitPatterns[10][7] = {
{1, 1, 1, 1, 1, 1, 0}, // 0 coomon catoda dapat diketahui pada angka nol dominan 1
{0, 1, 1, 0, 0, 0, 0}, // 1
{1, 1, 0, 1, 1, 0, 1}, // 2
{1, 1, 1, 1, 0, 0, 1}, // 3
{0, 1, 1, 0, 0, 1, 1}, // 4
{1, 0, 1, 1, 0, 1, 1}, // 5
{1, 0, 1, 1, 1, 1, 1}, // 6
{1, 1, 1, 0, 0, 0, 0}, // 7
{1, 1, 1, 1, 1, 1, 1}, // 8
{1, 1, 1, 1, 0, 1, 1} // 9
};
byte digitlei[3][7] = {
{0, 1, 1, 1, 1, 0, 1}, // d
{0, 0, 0, 1, 1, 1, 1}, // t
{1, 1, 0, 1, 1, 1, 1}, // e
};
byte digitclear[1][7] ={
{1,1,1,1,1,1,1},
};
void setup() {
for (int i = 0; i < 7; i++) {
pinMode(segments[i], OUTPUT);
}
pinMode(dp, OUTPUT);
pinMode(Dsw1, INPUT_PULLUP);
pinMode(Dsw2, INPUT_PULLUP);
pinMode(Dsw3, INPUT_PULLUP);
pinMode(Dsw4, INPUT_PULLUP);
Serial.begin(9600);
}
void number(int display) {
if (display >= 0 && display <= 9) {
for (int i = 0; i < 7; i++) {
digitalWrite(segments[i], digitPatterns[display][i]);
}
}
}
void clear(){
for (int i = 0; i < 7; i++) {
digitalWrite(segments[i], digitclear[0][i]);
}
}
void loop() {
int sw1 = digitalRead(Dsw1);
int sw2 = digitalRead(Dsw2);
int sw3 = digitalRead(Dsw3);
int sw4 = digitalRead(Dsw4);
int x=sw1+sw2+sw3+sw4;
if (x==3){
number(1);
delay(1000);
number(2);
delay(1000);
number(3);
delay(1000);
for (int i = 0; i < 7; i++) {
digitalWrite(segments[i], digitlei[0][i]);
} delay (1000);
for (int i = 0; i < 7; i++) {
digitalWrite(segments[i], digitlei[1][i]);
} delay (1000);
for (int i = 0; i < 7; i++) {
digitalWrite(segments[i], digitlei[2][i]);
} delay (1000);
}
else{
}
}
Video Percobaan klik disini
Tidak ada komentar:
Posting Komentar