Update of this article Here
The way these 4 seven segments work is like the usual seven segments, but we need to determine which one will light up. Then then only one can be chosen? Yes it is true, but if it is placed inside looping, it will happen 60 iteration every second and the human eye will see it as all flame. So this is not a problem
Put A in no 2 dst, G at no 8. D1 at no 9 dst D4 at no 12
Arduino Code
#define A 2#define B 3#define C 4#define D 5#define E 6const int F=7;#define G 8#define D1 9#define D2 10#define D3 11#define D4 12void setup() {// put your setup code here, to run once:pinMode(A, OUTPUT);pinMode(B, OUTPUT);pinMode(C, OUTPUT);pinMode(D, OUTPUT);pinMode(E, OUTPUT);pinMode(F, OUTPUT);pinMode(G, OUTPUT);pinMode(D1, OUTPUT);pinMode(D2, OUTPUT);pinMode(D3, OUTPUT);pinMode(D4, OUTPUT);Serial.begin(9600);}void char_A(){digitalWrite(D, HIGH);digitalWrite(E, LOW);digitalWrite(F, LOW);digitalWrite(G, LOW);digitalWrite(A, LOW);digitalWrite(B, LOW);digitalWrite(C, LOW);}void char_B(){//Displays BdigitalWrite(D, LOW);digitalWrite(E, LOW);digitalWrite(F, LOW);digitalWrite(G, LOW);digitalWrite(A, HIGH);digitalWrite(B, HIGH);digitalWrite(C, LOW);}void char_C(){//Displays CdigitalWrite(D, LOW);digitalWrite(E, LOW);digitalWrite(F, LOW);digitalWrite(G, HIGH);digitalWrite(A, LOW);digitalWrite(B, HIGH);digitalWrite(C, HIGH);}void char_D(){//Displays DdigitalWrite(D, LOW);digitalWrite(E, LOW);digitalWrite(F, HIGH);digitalWrite(G, LOW);digitalWrite(A, HIGH);digitalWrite(B, LOW);digitalWrite(C, LOW);}void char_E(){//Displays EdigitalWrite(D, LOW);digitalWrite(E, LOW);digitalWrite(F, LOW);digitalWrite(G, LOW);digitalWrite(A, LOW);digitalWrite(B, HIGH);digitalWrite(C, HIGH);}void char_F(){//Displays FdigitalWrite(D, HIGH);digitalWrite(E, LOW);digitalWrite(F, LOW);digitalWrite(G, LOW);digitalWrite(A, LOW);digitalWrite(B, HIGH);digitalWrite(C, HIGH);}void one(){//Displays 1digitalWrite(D, HIGH);digitalWrite(E, LOW);digitalWrite(F, LOW);digitalWrite(G, HIGH);digitalWrite(A, HIGH);digitalWrite(B, HIGH);digitalWrite(C, HIGH);}void two(){//Displays 2digitalWrite(D, LOW);digitalWrite(E, LOW);digitalWrite(F, HIGH);digitalWrite(G, LOW);digitalWrite(A, LOW);digitalWrite(B, LOW);digitalWrite(C, HIGH);}void three(){//Displays 3digitalWrite(D, LOW);digitalWrite(E, HIGH);digitalWrite(F, HIGH);digitalWrite(G, LOW);digitalWrite(A, LOW);digitalWrite(B, LOW);digitalWrite(C, LOW);}void four(){//Displays 4digitalWrite(D, HIGH);digitalWrite(E, HIGH);digitalWrite(F, LOW);digitalWrite(G, LOW);digitalWrite(A, HIGH);digitalWrite(B, LOW);digitalWrite(C, LOW);}void five(){//Displays 5digitalWrite(D, LOW);digitalWrite(E, HIGH);digitalWrite(F, LOW);digitalWrite(G, LOW);digitalWrite(A, LOW);digitalWrite(B, HIGH);digitalWrite(C, LOW);}void six(){//Displays 6digitalWrite(D, LOW);digitalWrite(E, LOW);digitalWrite(F, LOW);digitalWrite(G, LOW);digitalWrite(A, LOW);digitalWrite(B, HIGH);digitalWrite(C, LOW);}void seven(){//Displays 7digitalWrite(D, HIGH);digitalWrite(E, HIGH);digitalWrite(F, HIGH);digitalWrite(G, HIGH);digitalWrite(A, LOW);digitalWrite(B, LOW);digitalWrite(C, LOW);}void eight(){//Displays 8digitalWrite(D, LOW);digitalWrite(E, LOW);digitalWrite(F, LOW);digitalWrite(G, LOW);digitalWrite(A, LOW);digitalWrite(B, LOW);digitalWrite(C, LOW);}void nine(){//Displays 9digitalWrite(D, LOW);digitalWrite(E, HIGH);digitalWrite(F, LOW);digitalWrite(G, LOW);digitalWrite(A, LOW);digitalWrite(B, LOW);digitalWrite(C, LOW);}void zero(){//Displays 0digitalWrite(D, LOW);digitalWrite(E, LOW);digitalWrite(F, LOW);digitalWrite(G, HIGH);digitalWrite(A, LOW);digitalWrite(B, LOW);digitalWrite(C, LOW);}void LoopDisplay(int urutan){//Loop through all Chars and NumbersdigitalWrite(urutan,HIGH);char_A();delay(1000);char_B();delay(1000);char_C();delay(1000);char_D();delay(1000);char_E();delay(1000);char_F();delay(1000);one();delay(1000);two();delay(1000);three();delay(1000);four();delay(1000);five();delay(1000);six();delay(1000);seven();delay(1000);eight();delay(1000);nine();delay(1000);zero();delay(1000);digitalWrite(urutan,LOW);}void jam(){unsigned long waktu = millis();waktu/=1000;digitalWrite(D4,HIGH);angkatoled(waktu%10);waktu/=10;digitalWrite(D4,LOW);digitalWrite(D3,HIGH);angkatoled(waktu%10);waktu/=10;digitalWrite(D3,LOW);digitalWrite(D2,HIGH);angkatoled(waktu%10);waktu/=10;digitalWrite(D2,LOW);digitalWrite(D1,HIGH);angkatoled(waktu%10);waktu/=10;digitalWrite(D1,LOW);}void angkatoled(int angka){switch(angka){case 0:zero();break;case 1:one();break;case 2:two();break;case 3:three();break;case 4:four();break;case 5:five();break;case 6:six();break;case 7:seven();break;case 8:eight();break;case 9:nine();break;}}void loop() {// put your main code here, to run repeatedly:/* LoopDisplay(D1);LoopDisplay(D2);LoopDisplay(D3);LoopDisplay(D4);*/jam();}
Comments
Post a Comment