Seven segment ini tersusun atas 7 buah LED yang membentuk membentuk angka atau huruf dimana penyusunnya menggunakan label dari ‘a’ sampai ‘g’ dan satu lagi untuk dot point (DP). Salah satu terminal LED dihubungkan menjadi satu sebagai kaki common (biasanya pin-nya berada ditengah) .
Pin 3 dan 8 = untuk mengaktifkan seven segment diberikan logika high (common anode) dan logika low (common cathode).
Jenis-jenis Seven Segment :
1. Common Anoda
Semua anoda dari LED dalam seven segment disatukan secara parallel dan semua itu dihubungkan ke VCC, dan kemudian LED dihubungkan melalui tahanan pembatas arus keluar dari penggerak LED. Karena dihubungkan ke VCC, maka COMMON ANODA ini berada pada kondisi AKTIF LOW (led akan menyala/aktif bila diberi logika 0).
2. Common Katoda
Merupakan kebalikan dari Common Anoda. Disini semua katoda disatukan secara parallel dan dihubungkan ke GROUND. Karena seluruh katoda dihubungkan ke GROUND, maka COMMON KATODA ini berada pada kondisi AKTIF HIGH (led akan menyala/aktif bila diberi logika 1).
Prinsip Kerja :
Prinsip kerja seven segment ialah input biner pada switch dikonversikan masuk ke dalam decoder, baru kemudian decoder mengkonversi bilangan biner tersebut menjadi decimal, yang nantinya akan ditampilkan pada seven segment.
Seven segment dapat menampilkan angka-angka desimal dan beberapa karakter tertentu melalui kombinasi aktif atau tidaknya LED dalam seven segment. Untuk memudahkan penggunaan seven segment, umumnya digunakan sebuah decoder( mengubah/ mengkoversi input bilangan biner menjadi decimal) atau seven segment driver yang akan mengatur aktif tidaknya led-led dalam seven segment sesuai dengan nilai biner yang diberikan.
Dekoder BCD ke seven segment digunakan untuk menerima masukan BCD 4-bit dan memberikan keluaran yang melewatkan arus melalui segmen untuk menampilkan angka desimal. Jenis dekoder BCD ke seven segment ada dua macam yaitu dekoder yang berfungsi untuk menyalakan seven segment mode common anoda dan dekoder yang berfungsi untuk menyalakan seven segment mode common katoda.
Komponen yang diperlukan
Seven segment x 2
Resistor 220Ω X 2
Bread board kecil x 2
Kabel jumper
Koneksi Rangkaian
Yang perlu diperhatikan pada seven segment adalah seven segment yang di gunakan apakah Common katoda, atau common anoda.
1. Rangkaian Satu Seven segment
Penulisan Program
#define A 8
#define B 9
#define C 2
#define D 3
#define E 4
#define F 6
#define G 5
void clr(){ //Clear seven segment
digitalWrite(A, LOW);
digitalWrite(B, LOW);
digitalWrite(C, LOW);
digitalWrite(D, LOW);
digitalWrite(E, LOW);
digitalWrite(F, LOW);
digitalWrite(G, LOW);
}
void kar_A(){
digitalWrite(A, HIGH);
digitalWrite(B, HIGH);
digitalWrite(C, HIGH);
digitalWrite(D, LOW);
digitalWrite(E, HIGH);
digitalWrite(F, HIGH);
digitalWrite(G, HIGH);
}
void kar_B(){
digitalWrite(A, LOW);
digitalWrite(B, LOW);
digitalWrite(C, HIGH);
digitalWrite(D, HIGH);
digitalWrite(E, HIGH);
digitalWrite(F, HIGH);
digitalWrite(G, HIGH);
}
void kar_C(){
digitalWrite(A, HIGH);
digitalWrite(B, LOW);
digitalWrite(C, LOW);
digitalWrite(D, HIGH);
digitalWrite(E, HIGH);
digitalWrite(F, LOW);
digitalWrite(G, HIGH);
}
void kar_D(){
digitalWrite(A, LOW);
digitalWrite(B, HIGH);
digitalWrite(C, HIGH);
digitalWrite(D, HIGH);
digitalWrite(E, HIGH);
digitalWrite(F, HIGH);
digitalWrite(G, LOW);
}
void kar_E(){
digitalWrite(A, HIGH);
digitalWrite(B, LOW);
digitalWrite(C, LOW);
digitalWrite(D, HIGH);
digitalWrite(E, HIGH);
digitalWrite(F, HIGH);
digitalWrite(G, HIGH);
}
void kar_F(){
digitalWrite(A, HIGH);
digitalWrite(B, LOW);
digitalWrite(C, LOW);
digitalWrite(D, LOW);
digitalWrite(E, HIGH);
digitalWrite(F, HIGH);
digitalWrite(G, HIGH);
}
void kar_G(){
digitalWrite(A, HIGH);
digitalWrite(B, HIGH);
digitalWrite(C, HIGH);
digitalWrite(D, HIGH);
digitalWrite(E, LOW);
digitalWrite(F, HIGH);
digitalWrite(G, HIGH);
}
void kar_H(){
digitalWrite(A, LOW);
digitalWrite(B, HIGH);
digitalWrite(C, HIGH);
digitalWrite(D, LOW);
digitalWrite(E, HIGH);
digitalWrite(F, HIGH);
digitalWrite(G, HIGH);
}
void kar_I(){
digitalWrite(A, LOW);
digitalWrite(B, HIGH);
digitalWrite(C, HIGH);
digitalWrite(D, LOW);
digitalWrite(E, LOW);
digitalWrite(F, LOW);
digitalWrite(G, LOW);
}
void kar_J(){
digitalWrite(A, HIGH);
digitalWrite(B, HIGH);
digitalWrite(C, HIGH);
digitalWrite(D, HIGH);
digitalWrite(E, HIGH);
digitalWrite(F, LOW);
digitalWrite(G, LOW);
}
void satu(){
digitalWrite(A, LOW);
digitalWrite(B, LOW);
digitalWrite(C, LOW);
digitalWrite(D, LOW);
digitalWrite(E, HIGH);
digitalWrite(F, LOW);
digitalWrite(G, HIGH);
}
void dua(){
digitalWrite(A, HIGH);
digitalWrite(B, HIGH);
digitalWrite(C, LOW);
digitalWrite(D, HIGH);
digitalWrite(E, HIGH);
digitalWrite(F, HIGH);
digitalWrite(G, LOW);
}
void tiga(){
digitalWrite(A, HIGH);
digitalWrite(B, HIGH);
digitalWrite(C, HIGH);
digitalWrite(D, HIGH);
digitalWrite(E, LOW);
digitalWrite(F, HIGH);
digitalWrite(G, LOW);
}
void empat(){
digitalWrite(A, LOW);
digitalWrite(B, HIGH);
digitalWrite(C, HIGH);
digitalWrite(D, LOW);
digitalWrite(E, LOW);
digitalWrite(F, HIGH);
digitalWrite(G, HIGH);
}
void lima(){
digitalWrite(A, HIGH);
digitalWrite(B, LOW);
digitalWrite(C, HIGH);
digitalWrite(D, HIGH);
digitalWrite(E, LOW);
digitalWrite(F, HIGH);
digitalWrite(G, HIGH);
}
void enam(){
digitalWrite(A, HIGH);
digitalWrite(B, LOW);
digitalWrite(C, HIGH);
digitalWrite(D, HIGH);
digitalWrite(E, HIGH);
digitalWrite(F, HIGH);
digitalWrite(G, HIGH);
}
void tujuh(){
digitalWrite(A, HIGH);
digitalWrite(B, HIGH);
digitalWrite(C, HIGH);
digitalWrite(D, LOW);
digitalWrite(E, LOW);
digitalWrite(F, LOW);
digitalWrite(G, LOW);
}
void delapan(){
digitalWrite(A, HIGH);
digitalWrite(B, HIGH);
digitalWrite(C, HIGH);
digitalWrite(D, HIGH);
digitalWrite(E, HIGH);
digitalWrite(F, HIGH);
digitalWrite(G, HIGH);
}
void sembilan(){
digitalWrite(A, HIGH);
digitalWrite(B, HIGH);
digitalWrite(C, HIGH);
digitalWrite(D, LOW);
digitalWrite(E, LOW);
digitalWrite(F, HIGH);
digitalWrite(G, HIGH);
}
void nol(){
digitalWrite(A, HIGH);
digitalWrite(B, HIGH);
digitalWrite(C, HIGH);
digitalWrite(D, HIGH);
digitalWrite(E, HIGH);
digitalWrite(F, LOW);
digitalWrite(G, HIGH);
}
void karangka(){ //Looping karakter dan angka
kar_A();
delay(1000);
kar_B();
delay(1000);
kar_C();
delay(1000);
kar_D();
delay(1000);
kar_E();
delay(1000);
kar_F();
delay(1000);
kar_G();
delay(1000);
kar_H();
delay(1000);
kar_I();
delay(1000);
kar_J();
delay(1000);
satu();
delay(1000);
dua();
delay(1000);
tiga();
delay(1000);
empat();
delay(1000);
lima();
delay(1000);
enam();
delay(1000);
tujuh();
delay(1000);
delapan();
delay(1000);
sembilan();
delay(1000);
nol();
delay(1000);
}
void setup(){ //Setup pin sebagai output
pinMode(A, OUTPUT);
pinMode(B, OUTPUT);
pinMode(C, OUTPUT);
pinMode(D, OUTPUT);
pinMode(E, OUTPUT);
pinMode(F, OUTPUT);
pinMode(G, OUTPUT);
}
void loop(){
karangka ();
}
2. Rangkaian Dua Seven segment
Penulisan Program
int pin1 = 2;
int pin2 = 3; // ---6---
int pin3 = 4; // 5 | | 7
int pin4 = 5; // |---4---|
int pin5 = 6; // 1 | | 3
int pin6 = 7; // ---2---
int pin7 = 8;
int cmm1 = 11; // Common katoda yang pertama
int cmm2 = 9; // Common katoda yang kedua
int timer =100; // timer, saat perpindahan antar karakter
int nilai;
void setup(){
pinMode(pin1, OUTPUT);
pinMode(pin2, OUTPUT);
pinMode(pin3, OUTPUT);
pinMode(pin4, OUTPUT); //Setting digital pin sebagai output
pinMode(pin5, OUTPUT);
pinMode(pin6, OUTPUT);
pinMode(pin7, OUTPUT);
pinMode(cmm1, OUTPUT);
pinMode(cmm2, OUTPUT);
}
void duapuluh() {
for (int i=0; i
digitalWrite(pin2, HIGH);
digitalWrite(pin3, LOW);
digitalWrite(pin4, HIGH);
digitalWrite(pin5, LOW);
digitalWrite(pin6, HIGH);
digitalWrite(pin7, HIGH);
digitalWrite(cmm1, LOW);
digitalWrite(cmm2, HIGH);
delay(1);
digitalWrite(pin1, HIGH);
digitalWrite(pin2, HIGH);
digitalWrite(pin3, HIGH);
digitalWrite(pin4, LOW);
digitalWrite(pin5, HIGH);
digitalWrite(pin6, HIGH);
digitalWrite(pin7, HIGH);
digitalWrite(cmm1, HIGH);
digitalWrite(cmm2, LOW);
delay(1);
}
}
void sembilanbelas(){
for (int i=0; i
digitalWrite(pin2, LOW);
digitalWrite(pin3, HIGH);
digitalWrite(pin4, LOW);
digitalWrite(pin5, LOW);
digitalWrite(pin6, LOW);
digitalWrite(pin7, HIGH);
digitalWrite(cmm1, LOW);
digitalWrite(cmm2, HIGH);
delay(1);
digitalWrite(pin1, LOW);
digitalWrite(pin2, LOW);
digitalWrite(pin3, HIGH);
digitalWrite(pin4, HIGH);
digitalWrite(pin5, HIGH);
digitalWrite(pin6, HIGH);
digitalWrite(pin7, HIGH);
digitalWrite(cmm1, HIGH);
digitalWrite(cmm2, LOW);
delay(1);
}
}
void delapanbelas(){
for (int i=0; i
digitalWrite(pin2, LOW);
digitalWrite(pin3, HIGH);
digitalWrite(pin4, LOW);
digitalWrite(pin5, LOW);
digitalWrite(pin6, LOW);
digitalWrite(pin7, HIGH);
digitalWrite(cmm1, LOW);
digitalWrite(cmm2, HIGH);
delay(1);
digitalWrite(pin1, HIGH);
digitalWrite(pin2, HIGH);
digitalWrite(pin3, HIGH);
digitalWrite(pin4, HIGH);
digitalWrite(pin5, HIGH);
digitalWrite(pin6, HIGH);
digitalWrite(pin7, HIGH);
digitalWrite(cmm1, HIGH);
digitalWrite(cmm2, LOW);
delay(1);
}
}
void tujuhbelas(){
for (int i=0; i
digitalWrite(pin2, LOW);
digitalWrite(pin3, HIGH);
digitalWrite(pin4, LOW);
digitalWrite(pin5, LOW);
digitalWrite(pin6, LOW);
digitalWrite(pin7, HIGH);
digitalWrite(gnd1, LOW);
digitalWrite(gnd2, HIGH);
delay(1);
digitalWrite(pin1, LOW);
digitalWrite(pin2, LOW);
digitalWrite(pin3, HIGH);
digitalWrite(pin4, LOW);
digitalWrite(pin5, LOW);
digitalWrite(pin6, HIGH);
digitalWrite(pin7, HIGH);
digitalWrite(cmm1, HIGH);
digitalWrite(cmm2, LOW);
delay(1);
}
}
void enambelas(){
for (int i=0; i
digitalWrite(pin2, LOW);
digitalWrite(pin3, HIGH);
digitalWrite(pin4, LOW);
digitalWrite(pin5, LOW);
digitalWrite(pin6, LOW);
digitalWrite(pin7, HIGH);
digitalWrite(cmm1, LOW);
digitalWrite(cmm2, HIGH);
delay(1);
digitalWrite(pin1, HIGH);
digitalWrite(pin2, HIGH);
digitalWrite(pin3, HIGH);
digitalWrite(pin4, HIGH);
digitalWrite(pin5, HIGH);
digitalWrite(pin6, HIGH);
digitalWrite(pin7, LOW);
digitalWrite(cmm1, HIGH);
digitalWrite(cmm2, LOW);
delay(1);
}
}
void limabelas(){
for (int i=0; i
digitalWrite(pin2, LOW);
digitalWrite(pin3, HIGH);
digitalWrite(pin4, LOW);
digitalWrite(pin5, LOW);
digitalWrite(pin6, LOW);
digitalWrite(pin7, HIGH);
digitalWrite(cmm1, LOW);
digitalWrite(cmm2, HIGH);
delay(1);
digitalWrite(pin1, LOW);
digitalWrite(pin2, HIGH);
digitalWrite(pin3, HIGH);
digitalWrite(pin4, HIGH);
digitalWrite(pin5, HIGH);
digitalWrite(pin6, HIGH);
digitalWrite(pin7, LOW);
digitalWrite(cmm1, HIGH);
digitalWrite(cmm2, LOW);
delay(1);
}
}
void empatbelas(){
for (int i=0; i
digitalWrite(pin2, LOW);
digitalWrite(pin3, HIGH);
digitalWrite(pin4, LOW);
digitalWrite(pin5, LOW);
digitalWrite(pin6, LOW);
digitalWrite(pin7, HIGH);
digitalWrite(cmm1, LOW);
digitalWrite(cmm2, HIGH);
delay(1);
digitalWrite(pin1, LOW);
digitalWrite(pin2, LOW);
digitalWrite(pin3, HIGH);
digitalWrite(pin4, HIGH);
digitalWrite(pin5, HIGH);
digitalWrite(pin6, LOW);
digitalWrite(pin7, HIGH);
digitalWrite(cmm1, HIGH);
digitalWrite(cmm2, LOW);
delay(1);
}
}
void tigabelas(){
for (int i=0; i
digitalWrite(pin2, LOW);
digitalWrite(pin3, HIGH);
digitalWrite(pin4, LOW);
digitalWrite(pin5, LOW);
digitalWrite(pin6, LOW);
digitalWrite(pin7, HIGH);
digitalWrite(cmm1, LOW);
digitalWrite(cmm2, HIGH);
delay(1);
digitalWrite(pin1, LOW);
digitalWrite(pin2, HIGH);
digitalWrite(pin3, HIGH);
digitalWrite(pin4, HIGH);
digitalWrite(pin5, LOW);
digitalWrite(pin6, HIGH);
digitalWrite(pin7, HIGH);
digitalWrite(cmm1, HIGH);
digitalWrite(cmm2, LOW);
delay(1);
}
}
void duabelas(){
for (int i=0; i
digitalWrite(pin2, LOW);
digitalWrite(pin3, HIGH);
digitalWrite(pin4, LOW);
digitalWrite(pin5, LOW);
digitalWrite(pin6, LOW);
digitalWrite(pin7, HIGH);
digitalWrite(cmm1, LOW);
digitalWrite(cmm2, HIGH);
delay(1);
digitalWrite(pin1, HIGH);
digitalWrite(pin2, HIGH);
digitalWrite(pin3, LOW);
digitalWrite(pin4, HIGH);
digitalWrite(pin5, LOW);
digitalWrite(pin6, HIGH);
digitalWrite(pin7, HIGH);
digitalWrite(cmm1, HIGH);
digitalWrite(cmm2, LOW);
delay(1);
}
}
void sebelas(){
for (int i=0; i
digitalWrite(pin2, LOW);
digitalWrite(pin3, HIGH);
digitalWrite(pin4, LOW);
digitalWrite(pin5, LOW);
digitalWrite(pin6, LOW);
digitalWrite(pin7, HIGH);
digitalWrite(cmm1, LOW);
digitalWrite(cmm2, HIGH);
delay(1);
digitalWrite(pin1, LOW);
digitalWrite(pin2, LOW);
digitalWrite(pin3, HIGH);
digitalWrite(pin4, LOW);
digitalWrite(pin5, LOW);
digitalWrite(pin6, LOW);
digitalWrite(pin7, HIGH);
digitalWrite(cmm1, HIGH);
digitalWrite(cmm2, LOW);
delay(1);
}
}
void sepuluh(){
for (int i=0; i
digitalWrite(pin2, LOW);
digitalWrite(pin3, HIGH);
digitalWrite(pin4, LOW);
digitalWrite(pin5, LOW);
digitalWrite(pin6, LOW);
digitalWrite(pin7, HIGH);
digitalWrite(cmm1, LOW);
digitalWrite(cmm2, HIGH);
delay(1);
digitalWrite(pin1, HIGH);
digitalWrite(pin2, HIGH);
digitalWrite(pin3, HIGH);
digitalWrite(pin4, LOW);
digitalWrite(pin5, HIGH);
digitalWrite(pin6, HIGH);
digitalWrite(pin7, HIGH);
digitalWrite(cmm1, HIGH);
digitalWrite(cmm2, LOW);
delay(1);
}
}
void sembilan(){
for (int i=0; i
digitalWrite(pin2, HIGH);
digitalWrite(pin3, HIGH);
digitalWrite(pin4, LOW);
digitalWrite(pin5, HIGH);
digitalWrite(pin6, HIGH);
digitalWrite(pin7, HIGH);
digitalWrite(cmm1, LOW);
digitalWrite(cmm2, HIGH);
delay(1);
digitalWrite(pin1, LOW);
digitalWrite(pin2, LOW);
digitalWrite(pin3, HIGH);
digitalWrite(pin4, HIGH);
digitalWrite(pin5, HIGH);
digitalWrite(pin6, HIGH);
digitalWrite(pin7, HIGH);
digitalWrite(cmm1, HIGH);
digitalWrite(cmm2, LOW);
delay(1);
}
}
void delapan(){
for (int i=0; i
digitalWrite(pin2, HIGH);
digitalWrite(pin3, HIGH);
digitalWrite(pin4, LOW);
digitalWrite(pin5, HIGH);
digitalWrite(pin6, HIGH);
digitalWrite(pin7, HIGH);
digitalWrite(cmm1, LOW);
digitalWrite(cmm2, HIGH);
delay(1);
digitalWrite(pin1, HIGH);
digitalWrite(pin2, HIGH);
digitalWrite(pin3, HIGH);
digitalWrite(pin4, HIGH);
digitalWrite(pin5, HIGH);
digitalWrite(pin6, HIGH);
digitalWrite(pin7, HIGH);
digitalWrite(cmm1, HIGH);
digitalWrite(cmm2, LOW);
delay(1);
}
}
void tujuh(){
for (int i=0; i
digitalWrite(pin2, HIGH);
digitalWrite(pin3, HIGH);
digitalWrite(pin4, LOW);
digitalWrite(pin5, HIGH);
digitalWrite(pin6, HIGH);
digitalWrite(pin7, HIGH);
digitalWrite(cmm1, LOW);
digitalWrite(cmm2, HIGH);
delay(1);
digitalWrite(pin1, LOW);
digitalWrite(pin2, LOW);
digitalWrite(pin3, HIGH);
digitalWrite(pin4, LOW);
digitalWrite(pin5, LOW);
digitalWrite(pin6, HIGH);
digitalWrite(pin7, HIGH);
digitalWrite(cmm1, HIGH);
digitalWrite(cmm2, LOW);
delay(1);
}
}
void enam(){
for (int i=0; i
digitalWrite(pin2, HIGH);
digitalWrite(pin3, HIGH);
digitalWrite(pin4, LOW);
digitalWrite(pin5, HIGH);
digitalWrite(pin6, HIGH);
digitalWrite(pin7, HIGH);
digitalWrite(cmm1, LOW);
digitalWrite(cmm2, HIGH);
delay(1);
digitalWrite(pin1, HIGH);
digitalWrite(pin2, HIGH);
digitalWrite(pin3, HIGH);
digitalWrite(pin4, HIGH);
digitalWrite(pin5, HIGH);
digitalWrite(pin6, HIGH);
digitalWrite(pin7, LOW);
digitalWrite(cmm1, HIGH);
digitalWrite(cmm2, LOW);
delay(1);
}
}
void lima(){
for (int i=0; i
digitalWrite(pin2, HIGH);
digitalWrite(pin3, HIGH);
digitalWrite(pin4, LOW);
digitalWrite(pin5, HIGH);
digitalWrite(pin6, HIGH);
digitalWrite(pin7, HIGH);
digitalWrite(cmm1, LOW);
digitalWrite(cmm2, HIGH);
delay(1);
digitalWrite(pin1, LOW);
digitalWrite(pin2, HIGH);
digitalWrite(pin3, HIGH);
digitalWrite(pin4, HIGH);
digitalWrite(pin5, HIGH);
digitalWrite(pin6, HIGH);
digitalWrite(pin7, LOW);
digitalWrite(cmm1, HIGH);
digitalWrite(cmm2, LOW);
delay(1);
}
}
void empat(){
for (int i=0; i
digitalWrite(pin2, HIGH);
digitalWrite(pin3, HIGH);
digitalWrite(pin4, LOW);
digitalWrite(pin5, HIGH);
digitalWrite(pin6, HIGH);
digitalWrite(pin7, HIGH);
digitalWrite(cmm1, LOW);
digitalWrite(cmm2, HIGH);
delay(1);
digitalWrite(pin1, LOW);
digitalWrite(pin2, LOW);
digitalWrite(pin3, HIGH);
digitalWrite(pin4, HIGH);
digitalWrite(pin5, HIGH);
digitalWrite(pin6, LOW);
digitalWrite(pin7,HIGH);
digitalWrite(cmm1, HIGH);
digitalWrite(cmm2, LOW);
delay(1);
}
}
void tiga(){
for (int i=0; i
digitalWrite(pin2, HIGH);
digitalWrite(pin3, HIGH);
digitalWrite(pin4, LOW);
digitalWrite(pin5, HIGH);
digitalWrite(pin6, HIGH);
digitalWrite(pin7, HIGH);
digitalWrite(cmm1, LOW);
digitalWrite(cmm2, HIGH);
delay(1);
digitalWrite(pin1, LOW);
digitalWrite(pin2, HIGH);
digitalWrite(pin3, HIGH);
digitalWrite(pin4, HIGH);
digitalWrite(pin5, LOW);
digitalWrite(pin6, HIGH);
digitalWrite(pin7,HIGH);
digitalWrite(cmm1, HIGH);
digitalWrite(cmm2, LOW);
delay(1);
}
}
void dua(){
for (int i=0; i
digitalWrite(pin2, HIGH);
digitalWrite(pin3, HIGH);
digitalWrite(pin4, LOW);
digitalWrite(pin5, HIGH);
digitalWrite(pin6, HIGH);
digitalWrite(pin7, HIGH);
digitalWrite(cmm1, LOW);
digitalWrite(cmm2, HIGH);
delay(1);
digitalWrite(pin1, HIGH);
digitalWrite(pin2, HIGH);
digitalWrite(pin3, LOW);
digitalWrite(pin4, HIGH);
digitalWrite(pin5, LOW);
digitalWrite(pin6, HIGH);
digitalWrite(pin7, HIGH);
digitalWrite(cmm1, HIGH);
digitalWrite(cmm2, LOW);
delay(1);
}
}
void satu(){
for (int i=0; i
digitalWrite(pin2, HIGH);
digitalWrite(pin3, HIGH);
digitalWrite(pin4, LOW);
digitalWrite(pin5, HIGH);
digitalWrite(pin6, HIGH);
digitalWrite(pin7, HIGH);
digitalWrite(cmm1, LOW);
digitalWrite(cmm2, HIGH);
delay(1);
digitalWrite(pin1, LOW);
digitalWrite(pin2, LOW);
digitalWrite(pin3, HIGH);
digitalWrite(pin4, LOW);
digitalWrite(pin5, LOW);
digitalWrite(pin6, LOW);
digitalWrite(pin7, HIGH);
digitalWrite(cmm1, HIGH);
digitalWrite(cmm2, LOW);
delay(1);
}
}
void nol(){
for (int i=0; i
digitalWrite(pin2, HIGH);
digitalWrite(pin3, HIGH);
digitalWrite(pin4, LOW);
digitalWrite(pin5, HIGH);
digitalWrite(pin6, HIGH);
digitalWrite(pin7, HIGH);
digitalWrite(cmm1, LOW);
digitalWrite(cmm2, HIGH);
delay(1);
digitalWrite(pin1, HIGH);
digitalWrite(pin2, HIGH);
digitalWrite(pin3, HIGH);
digitalWrite(pin4, LOW);
digitalWrite(pin5, HIGH);
digitalWrite(pin6, HIGH);
digitalWrite(pin7, HIGH);
digitalWrite(cmm1, HIGH);
digitalWrite(cmm2, LOW);
delay(1);
}
}
void loop() {
for(nilai = 0 ; nilai <= 255; nilai+=5){ // kedip pelan dari min ke max
analogWrite(cmm1, nilai);
analogWrite(cmm2, nilai);
delay(10);
}
for(nilai = 255; nilai >=0; nilai-=5){ //kedip pelan dari max ke min
analogWrite(cmm1,nilai);
analogWrite(cmm2, nilai);
delay(10);
}
duapuluh();
sembilanbelas();
delapanbelas();
tujuhbelas();
enambelas();
limabelas();
empatbelas();
tigabelas();
duabelas();
sebelas();
sepuluh();
sembilan();
delapan();
tujuh();
enam();
lima();
empat();
tiga();
dua();
satu();
nol();
}