Rakit Sendiri Jam Digital Mu
Berjumpa lagi bersama saya Kharifans Art...
Postingan Kali Ini ,bukan masalah bagaimana Cara melupakan seseorang yang
kita Cintai ...hehehehe...masalah perasaan ni ceritanya..
melainkan postingan kali ini cara membuat Jam Digital seven segmen Dengan arduino,Lagi-lagi
Arduino,.Kenepa Harus Arduino sih....
iya Kerna Arduino merupakan bahasa Pemerograman Mikrokontroler yg paling Mudah Di pelajari (Open Source)
Tahun Dulu saya pernah Membuat Jam digital dengan bahasa pemerograman Asemble
dan kali ini saya mencoba membuat jam Digital Dengan Arduino,
ok langsung saja gays.
Jam digital kali ini berbasiskan arduino yang menggunakan IC ATMEGA328. Dalam proyek ini saya menggunakan Aruino Uno yang mudah didapatkan. Jam digital
ini sudah dilengkapi dengan sebuah IC RTC, yaitu sebuah IC yang dapat menyimpan data waktu maupun tanggal,
walaupun power supply untuk jam itu sendiri mati.
Agar jam digital ini dapat terus meng-counter waktu pada saat listrik padam, maka diperlukan nya sebuah battery backup untuk tenaga cadangan
bagi IC RTC hingga berbulan bulan lamanya tanpa ada arus listrik ke rangkaian jam digital.
Jam digital ini bisa menggunakan display seven segmen common anoda maupun common catoda tergantung dari pemasangan transistor driver terhadap seven segmen.
Pada jam digital ini dilengkapi dengan 2 tombol yang dapat digunakan untuk mengatur jam, menit saja.
Rangkaian RTC

Skematic Sevensegmen
Full skematic
Source code
//=====================================================
// Jam Digital Seven Segmen
// By : Kharifans_Art
//======================================================
#include "Wire.h"
#include "RTClib.h"
RTC_DS1307 RTC;
//time variables
int hh24;
int hh;
int mm;
int ss;
//I/O
int hoursButton = A1;
int minsButton = A0;
//segments
int segA = 0;
int segB = 1;
int segC = 2;
int segD = 3;
int segE = 4;
int segF = 5;
int segG = 6;
int decimal = 7;
//digits
int hhDigit2 = 13;
int hhDigit1 = 12;
int mmDigit2 = 11;
int mmDigit1 = 10;
int ssDigit2 = 9;
int ssDigit1 = 8;
//digit variables
//hours
byte digit6;
byte digit5;
//minutes
byte digit4;
byte digit3;
//seconds
byte digit2;
byte digit1;
//segment array (configured for upside-down displays) (common cathode driven by 3904 NPNs)
byte segArray[11][7] = {{1,1,1,1,1,1,0}, // 0
{0,0,0,0,1,1,0}, // 1
{1,1,0,1,1,0,1}, // 2
{1,0,0,1,1,1,1}, // 3
{0,0,1,0,1,1,1}, // 4
{1,0,1,1,0,1,1}, // 5
{1,1,1,1,0,1,1}, // 6
{0,0,0,1,1,1,0}, // 7
{1,1,1,1,1,1,1}, // 8
{1,0,1,1,1,1,1}, // 9
{0,0,0,0,0,0,0} // off
};
volatile byte multiplexer = 0;
void setup() {
Wire.begin();
RTC.begin();
//set pin modes
pinMode(segA, OUTPUT);
pinMode(segB, OUTPUT);
pinMode(segC, OUTPUT);
pinMode(segD, OUTPUT);
pinMode(segE, OUTPUT);
pinMode(segF, OUTPUT);
pinMode(segG, OUTPUT);
pinMode(decimal, OUTPUT);
pinMode(hhDigit2, OUTPUT);
pinMode(hhDigit1, OUTPUT);
pinMode(mmDigit2, OUTPUT);
pinMode(mmDigit1, OUTPUT);
pinMode(ssDigit2, OUTPUT);
pinMode(ssDigit1, OUTPUT);
pinMode(hoursButton, INPUT);
pinMode(minsButton, INPUT);
//set states
digitalWrite(segA, HIGH);
digitalWrite(segB, HIGH);
digitalWrite(segC, HIGH);
digitalWrite(segD, HIGH);
digitalWrite(segE, HIGH);
digitalWrite(segF, HIGH);
digitalWrite(segG, HIGH);
digitalWrite(decimal, LOW);
}
void loop() {
DateTime now = RTC.now(); //time from the RTC in 24 hour mode
hh24 = now.hour(); //used for PM check
mm = now.minute();
ss = now.second();
//pass RTC values into a new variable -
//this way one variable stores time in 24 hour mode and another that can be converted to 12 hour mode
//time is monitored 'in the background' in 24 hour mode using the RTC, but is displayed in an adjusted 12-hr format
hh = hh24;
//convert to 12 hr mode for display
if (hh24 < 1) {
hh = 12;
}
if ((hh24 > 12) && (hh24 < 24)) {
hh = hh24 - 12;
}
//turn on PM light as appropriate
if (hh24 > 11) {
digitalWrite(decimal, HIGH);
}
else {
digitalWrite(decimal, LOW);
}
//calculate the number to be displayed on each digit by disecting the time from the RTC
//hours
digit5 = hh / 10;
digit6 = hh % 10;
//minutes
digit3 = mm / 10;
digit4 = mm % 10;
//seconds
digit1 = ss / 10;
digit2 = ss % 10;
//turn digits off
digitalWrite(ssDigit1, LOW); //1st digit - 1s of seconds
digitalWrite(ssDigit2, LOW); //2nd digit - 10s of seconds
digitalWrite(mmDigit1, LOW); //3rd digit - 1s of minutes
digitalWrite(mmDigit2, LOW); //4th digit - 10s of minutes
digitalWrite(hhDigit1, LOW); //5th digit - 1s of hours
digitalWrite(hhDigit2, LOW); //6th digit - 10s of hours
//do the multiplexing...
multiplexer++;
if (multiplexer == 7) multiplexer = 1; //digits 6...1, then repeat
// 6th digit
if (multiplexer == 1) {
displayDigit(digit6); //get value
digitalWrite(hhDigit2, HIGH); //enable
}
// 5th digit
if (multiplexer == 2) {
displayDigit(digit5); //get value
digitalWrite(hhDigit1, HIGH); //enable
}
// 4th digit
if (multiplexer == 3) {
displayDigit(digit4); //get value
digitalWrite(mmDigit2, HIGH); //enable
}
// 3rd digit
if (multiplexer == 4) {
displayDigit(digit3); //get value
digitalWrite(mmDigit1, HIGH); //enable
}
// 2nd digit
if (multiplexer == 5) {
displayDigit(digit2); //get value
digitalWrite(ssDigit2, HIGH); //enable
}
// 1st digit
if (multiplexer == 6) {
displayDigit(digit1); //get value
digitalWrite(ssDigit1, HIGH); //enable
}
//handle button presses for setting the time
//hours button pressed
if (digitalRead(hoursButton) == LOW) {
//debounce
delay(200);
hh24++;
if (hh24 > 23) {
hh24 = 0;
}
updateRTC();
}
//minutes button pressed
if (digitalRead(minsButton) == LOW) {
//debounce
delay(200);
mm++;
ss = 0;
if (mm >59) {
mm = 0;
}
updateRTC();
}
}
//get character from segment array
void displayDigit(byte seg) {
digitalWrite(0, segArray[seg][0]); //A
digitalWrite(1, segArray[seg][1]); //B
digitalWrite(2, segArray[seg][2]); //C
digitalWrite(3, segArray[seg][3]); //D
digitalWrite(4, segArray[seg][4]); //E
digitalWrite(5, segArray[seg][5]); //F
digitalWrite(6, segArray[seg][6]); //G
}
//for RTC
byte decToBcd(byte val) {
return ( (val/10*16) + (val%10) );
}
byte bcdToDec(byte val) {
return ( (val/16*10) + (val%16) );
}
void updateRTC() {
Wire.beginTransmission(104);
Wire.write(0);
Wire.write(decToBcd(ss));
Wire.write(decToBcd(mm));
Wire.write(decToBcd(hh24));
Wire.endTransmission();
}
semoga Postingan Kali Ini Dapat bermanfaat bagi temen-teman semua..
jika ada kesulitan dalam perakitan Jam digital di postingan kali ini silahkan Hubungi Saya Disini
Postingan Kali Ini ,bukan masalah bagaimana Cara melupakan seseorang yang
kita Cintai ...hehehehe...masalah perasaan ni ceritanya..
melainkan postingan kali ini cara membuat Jam Digital seven segmen Dengan arduino,Lagi-lagi
Arduino,.Kenepa Harus Arduino sih....
iya Kerna Arduino merupakan bahasa Pemerograman Mikrokontroler yg paling Mudah Di pelajari (Open Source)
Tahun Dulu saya pernah Membuat Jam digital dengan bahasa pemerograman Asemble
dan kali ini saya mencoba membuat jam Digital Dengan Arduino,
ok langsung saja gays.
Jam digital kali ini berbasiskan arduino yang menggunakan IC ATMEGA328. Dalam proyek ini saya menggunakan Aruino Uno yang mudah didapatkan. Jam digital
ini sudah dilengkapi dengan sebuah IC RTC, yaitu sebuah IC yang dapat menyimpan data waktu maupun tanggal,
walaupun power supply untuk jam itu sendiri mati.
Agar jam digital ini dapat terus meng-counter waktu pada saat listrik padam, maka diperlukan nya sebuah battery backup untuk tenaga cadangan
bagi IC RTC hingga berbulan bulan lamanya tanpa ada arus listrik ke rangkaian jam digital.
Jam digital ini bisa menggunakan display seven segmen common anoda maupun common catoda tergantung dari pemasangan transistor driver terhadap seven segmen.
Pada jam digital ini dilengkapi dengan 2 tombol yang dapat digunakan untuk mengatur jam, menit saja.
Rangkaian RTC

Skematic Sevensegmen
Full skematic
Source code
//=====================================================
// Jam Digital Seven Segmen
// By : Kharifans_Art
//======================================================
#include "Wire.h"
#include "RTClib.h"
RTC_DS1307 RTC;
//time variables
int hh24;
int hh;
int mm;
int ss;
//I/O
int hoursButton = A1;
int minsButton = A0;
//segments
int segA = 0;
int segB = 1;
int segC = 2;
int segD = 3;
int segE = 4;
int segF = 5;
int segG = 6;
int decimal = 7;
//digits
int hhDigit2 = 13;
int hhDigit1 = 12;
int mmDigit2 = 11;
int mmDigit1 = 10;
int ssDigit2 = 9;
int ssDigit1 = 8;
//digit variables
//hours
byte digit6;
byte digit5;
//minutes
byte digit4;
byte digit3;
//seconds
byte digit2;
byte digit1;
//segment array (configured for upside-down displays) (common cathode driven by 3904 NPNs)
byte segArray[11][7] = {{1,1,1,1,1,1,0}, // 0
{0,0,0,0,1,1,0}, // 1
{1,1,0,1,1,0,1}, // 2
{1,0,0,1,1,1,1}, // 3
{0,0,1,0,1,1,1}, // 4
{1,0,1,1,0,1,1}, // 5
{1,1,1,1,0,1,1}, // 6
{0,0,0,1,1,1,0}, // 7
{1,1,1,1,1,1,1}, // 8
{1,0,1,1,1,1,1}, // 9
{0,0,0,0,0,0,0} // off
};
volatile byte multiplexer = 0;
void setup() {
Wire.begin();
RTC.begin();
//set pin modes
pinMode(segA, OUTPUT);
pinMode(segB, OUTPUT);
pinMode(segC, OUTPUT);
pinMode(segD, OUTPUT);
pinMode(segE, OUTPUT);
pinMode(segF, OUTPUT);
pinMode(segG, OUTPUT);
pinMode(decimal, OUTPUT);
pinMode(hhDigit2, OUTPUT);
pinMode(hhDigit1, OUTPUT);
pinMode(mmDigit2, OUTPUT);
pinMode(mmDigit1, OUTPUT);
pinMode(ssDigit2, OUTPUT);
pinMode(ssDigit1, OUTPUT);
pinMode(hoursButton, INPUT);
pinMode(minsButton, INPUT);
//set states
digitalWrite(segA, HIGH);
digitalWrite(segB, HIGH);
digitalWrite(segC, HIGH);
digitalWrite(segD, HIGH);
digitalWrite(segE, HIGH);
digitalWrite(segF, HIGH);
digitalWrite(segG, HIGH);
digitalWrite(decimal, LOW);
}
void loop() {
DateTime now = RTC.now(); //time from the RTC in 24 hour mode
hh24 = now.hour(); //used for PM check
mm = now.minute();
ss = now.second();
//pass RTC values into a new variable -
//this way one variable stores time in 24 hour mode and another that can be converted to 12 hour mode
//time is monitored 'in the background' in 24 hour mode using the RTC, but is displayed in an adjusted 12-hr format
hh = hh24;
//convert to 12 hr mode for display
if (hh24 < 1) {
hh = 12;
}
if ((hh24 > 12) && (hh24 < 24)) {
hh = hh24 - 12;
}
//turn on PM light as appropriate
if (hh24 > 11) {
digitalWrite(decimal, HIGH);
}
else {
digitalWrite(decimal, LOW);
}
//calculate the number to be displayed on each digit by disecting the time from the RTC
//hours
digit5 = hh / 10;
digit6 = hh % 10;
//minutes
digit3 = mm / 10;
digit4 = mm % 10;
//seconds
digit1 = ss / 10;
digit2 = ss % 10;
//turn digits off
digitalWrite(ssDigit1, LOW); //1st digit - 1s of seconds
digitalWrite(ssDigit2, LOW); //2nd digit - 10s of seconds
digitalWrite(mmDigit1, LOW); //3rd digit - 1s of minutes
digitalWrite(mmDigit2, LOW); //4th digit - 10s of minutes
digitalWrite(hhDigit1, LOW); //5th digit - 1s of hours
digitalWrite(hhDigit2, LOW); //6th digit - 10s of hours
//do the multiplexing...
multiplexer++;
if (multiplexer == 7) multiplexer = 1; //digits 6...1, then repeat
// 6th digit
if (multiplexer == 1) {
displayDigit(digit6); //get value
digitalWrite(hhDigit2, HIGH); //enable
}
// 5th digit
if (multiplexer == 2) {
displayDigit(digit5); //get value
digitalWrite(hhDigit1, HIGH); //enable
}
// 4th digit
if (multiplexer == 3) {
displayDigit(digit4); //get value
digitalWrite(mmDigit2, HIGH); //enable
}
// 3rd digit
if (multiplexer == 4) {
displayDigit(digit3); //get value
digitalWrite(mmDigit1, HIGH); //enable
}
// 2nd digit
if (multiplexer == 5) {
displayDigit(digit2); //get value
digitalWrite(ssDigit2, HIGH); //enable
}
// 1st digit
if (multiplexer == 6) {
displayDigit(digit1); //get value
digitalWrite(ssDigit1, HIGH); //enable
}
//handle button presses for setting the time
//hours button pressed
if (digitalRead(hoursButton) == LOW) {
//debounce
delay(200);
hh24++;
if (hh24 > 23) {
hh24 = 0;
}
updateRTC();
}
//minutes button pressed
if (digitalRead(minsButton) == LOW) {
//debounce
delay(200);
mm++;
ss = 0;
if (mm >59) {
mm = 0;
}
updateRTC();
}
}
//get character from segment array
void displayDigit(byte seg) {
digitalWrite(0, segArray[seg][0]); //A
digitalWrite(1, segArray[seg][1]); //B
digitalWrite(2, segArray[seg][2]); //C
digitalWrite(3, segArray[seg][3]); //D
digitalWrite(4, segArray[seg][4]); //E
digitalWrite(5, segArray[seg][5]); //F
digitalWrite(6, segArray[seg][6]); //G
}
//for RTC
byte decToBcd(byte val) {
return ( (val/10*16) + (val%10) );
}
byte bcdToDec(byte val) {
return ( (val/16*10) + (val%16) );
}
void updateRTC() {
Wire.beginTransmission(104);
Wire.write(0);
Wire.write(decToBcd(ss));
Wire.write(decToBcd(mm));
Wire.write(decToBcd(hh24));
Wire.endTransmission();
}
semoga Postingan Kali Ini Dapat bermanfaat bagi temen-teman semua..
jika ada kesulitan dalam perakitan Jam digital di postingan kali ini silahkan Hubungi Saya Disini
sketch error mau dibagi bagikan ha ha ha ha
ReplyDelete