JAM DIGITAL DOT MATRIX BERBASIS MOKROKONTROLER
Di jaman yang semakin canggih ini dimana piranti elektronika berkembang secara pesat. Manusia sangat bergantung pada piranti elektronik. Manusia mempunyai kelemahan dalam membaca piranti analog. Untuk itu manusia mengembangkan piranti-piranti digital agar mempermudah dalam pebacaannya. disini saya ingin membuat jam digital dengan display-nya menggunakan dot matrix.
Disini saya menggunakan mikrokontroler jenis AVR yaitu ATMega16.saya menggunakan ATmega ini karena kapasitas memorinya besar guna menyimpan database karakter.berikut adalah gambar rangkaian minimum sistemnya.
Disini saya menggunakan mikrokontroler jenis AVR yaitu ATMega16.saya menggunakan ATmega ini karena kapasitas memorinya besar guna menyimpan database karakter.berikut adalah gambar rangkaian minimum sistemnya.
Untuk Update Waktunya,saya menggunakan IC RTC(Real Time Clock) DS1307. Saya menggunakan IC tipe ini karena penggunaannya yang mudah. Di dalam CVAVR sudah ada fungsi untuk mengirim dan menerima pembacaan RTC.
berikut adalah gambar skematik RTC.
untuk displaynya saya menggunakan dot matrix.Pengertian dari Dot matrix LED adalah kompulan dari led-led kecil yang dipakai dalam kemasan yang mirip dengan seven segment. Proses penggunaannya yaitu dengan proses scanning. Dot matrix LED yang digunakan pada proyek kali ini adalah dot matrix dengan banyak baris 7 buah dan kolom 5 buah. Proses scanning yang dimaksud adalah proses pemberian tegangan high pada kolom tertentu dan disertai pemberian tegangan low pada baris tertentu secara bersamaan.Contoh urutan scanning-nya sebagai berikut:
- Kolom pertama diberi tegangan high
- Pemilihan dot yang akan menyala didasarkan pada pemberian tegangan low pada baris yang diinginkan
- Ulang ke proses pertama untuk kolom berikutnya.
Urutan kerja seperti diatas adalah proses scanning. Jadi sebenarnya tampilan karakter pada dot matrix LED sebenarnya adalah proses menyala secara bergantian.
untuk rangkaian driver kolom dan baris adalah sebagai berikut:
untuk rangkaian driver kolom dan baris adalah sebagai berikut:
untuk driver kolom saya menggunakan IC register 74LS164 dan untuk driver barisnya saya menggunakan transistor 2n222.
berikut adalah listing program untuk ngecek apakah RTC sudah berfungsi:
#include <mega16.h>
// I2C Bus functions
#asm
.equ __i2c_port=0×15 ;PORTC
.equ __sda_bit=1
.equ __scl_bit=0
#endasm
#include <i2c.h>
// DS1307 Real Time Clock functions
#include <ds1307.h>
// Standard Input/Output functions
#include <stdio.h>
// Declare your global variables here
void main(void)
{
unsigned char tanggal=0,bulan=0,tahun=0;
unsigned char tanggal_t=0,bulan_t=0,tahun_t=0;
unsigned char jam=0,menit=0,detik=0;
unsigned char jam_t=0,menit_t=0,detik_t=0;
// Input/Output Ports initialization
// Port A initialization
// Func7=Out Func6=Out Func5=Out Func4=Out Func3=Out Func2=Out Func1=Out Func0=Out
// State7=0 State6=0 State5=0 State4=0 State3=0 State2=0 State1=0 State0=0
PORTA=0×00;
DDRA=0xFF;
// Port B initialization
// Func7=Out Func6=Out Func5=Out Func4=Out Func3=Out Func2=Out Func1=Out Func0=Out
// State7=0 State6=0 State5=0 State4=0 State3=0 State2=0 State1=0 State0=0
PORTB=0×00;
DDRB=0xFF;
// Port C initialization
// Func7=In Func6=In Func5=In Func4=In Func3=In Func2=In Func1=In Func0=In
// State7=T State6=T State5=T State4=T State3=T State2=T State1=T State0=T
PORTC=0×00;
DDRC=0×00;
// Port D initialization
// Func7=In Func6=In Func5=In Func4=In Func3=In Func2=In Func1=In Func0=In
// State7=T State6=T State5=T State4=T State3=T State2=T State1=T State0=T
PORTD=0×00;
DDRD=0×00;
// Timer/Counter 0 initialization
// Clock source: System Clock
// Clock value: Timer 0 Stopped
// Mode: Normal top=0xFF
// OC0 output: Disconnected
TCCR0=0×00;
TCNT0=0×00;
OCR0=0×00;
// Timer/Counter 1 initialization
// Clock source: System Clock
// Clock value: Timer1 Stopped
// Mode: Normal top=0xFFFF
// OC1A output: Discon.
// OC1B output: Discon.
// Noise Canceler: Off
// Input Capture on Falling Edge
// Timer1 Overflow Interrupt: Off
// Input Capture Interrupt: Off
// Compare A Match Interrupt: Off
// Compare B Match Interrupt: Off
TCCR1A=0×00;
TCCR1B=0×00;
TCNT1H=0×00;
TCNT1L=0×00;
ICR1H=0×00;
ICR1L=0×00;
OCR1AH=0×00;
OCR1AL=0×00;
OCR1BH=0×00;
OCR1BL=0×00;
// Timer/Counter 2 initialization
// Clock source: System Clock
// Clock value: Timer2 Stopped
// Mode: Normal top=0xFF
// OC2 output: Disconnected
ASSR=0×00;
TCCR2=0×00;
TCNT2=0×00;
OCR2=0×00;
// External Interrupt(s) initialization
// INT0: Off
// INT1: Off
// INT2: Off
MCUCR=0×00;
MCUCSR=0×00;
// Timer(s)/Counter(s) Interrupt(s) initialization
TIMSK=0×00;
// USART initialization
// Communication Parameters: 8 Data, 1 Stop, No Parity
// USART Receiver: On
// USART Transmitter: On
// USART Mode: Asynchronous
// USART Baud Rate: 9600
UCSRA=0×00;
UCSRB=0×18;
UCSRC=0×86;
UBRRH=0×00;
UBRRL=0x4D;
// Analog Comparator initialization
// Analog Comparator: Off
// Analog Comparator Input Capture by Timer/Counter 1: Off
ACSR=0×80;
SFIOR=0×00;
// ADC initialization
// ADC disabled
ADCSRA=0×00;
// SPI initialization
// SPI disabled
SPCR=0×00;
// TWI initialization
// TWI disabled
TWCR=0×00;
// I2C Bus initialization
i2c_init();
// DS1307 Real Time Clock initialization
// Square wave output on pin SQW/OUT: On
// Square wave frequency: 1Hz
rtc_init(0,1,0);
rtc_set_date(12,12,11);
rtc_set_time(21,0,0);
while (1)
{
rtc_get_date(&tanggal_t,&bulan_t,&tahun_t);
if(tanggal_t!=tanggal||bulan_t!=bulan || tahun_t!=tahun)
{
tanggal=tanggal_t;
bulan=bulan_t;
tahun=tahun_t;
printf(“Tanggal: %d-%d-%d\n”,tanggal,bulan,tahun);
}
rtc_get_time(&jam_t,&menit_t,&detik_t);
if(jam_t!=jam||menit_t!=menit||detik_t!=detik)
{
jam=jam_t;
menit=menit_t;
detik=detik_t;
printf(“Waktu : %d:d:d\n”,jam,menit,detik);
}
};
}
untuk listing program menampilkan jam:
// I2C Bus functions
#asm
.equ __i2c_port=0×15 ;PORTC
.equ __sda_bit=1
.equ __scl_bit=0
#endasm
#include <i2c.h>
// DS1307 Real Time Clock functions
#include <ds1307.h>
// Standard Input/Output functions
#include <stdio.h>
// Declare your global variables here
void main(void)
{
unsigned char tanggal=0,bulan=0,tahun=0;
unsigned char tanggal_t=0,bulan_t=0,tahun_t=0;
unsigned char jam=0,menit=0,detik=0;
unsigned char jam_t=0,menit_t=0,detik_t=0;
// Input/Output Ports initialization
// Port A initialization
// Func7=Out Func6=Out Func5=Out Func4=Out Func3=Out Func2=Out Func1=Out Func0=Out
// State7=0 State6=0 State5=0 State4=0 State3=0 State2=0 State1=0 State0=0
PORTA=0×00;
DDRA=0xFF;
// Port B initialization
// Func7=Out Func6=Out Func5=Out Func4=Out Func3=Out Func2=Out Func1=Out Func0=Out
// State7=0 State6=0 State5=0 State4=0 State3=0 State2=0 State1=0 State0=0
PORTB=0×00;
DDRB=0xFF;
// Port C initialization
// Func7=In Func6=In Func5=In Func4=In Func3=In Func2=In Func1=In Func0=In
// State7=T State6=T State5=T State4=T State3=T State2=T State1=T State0=T
PORTC=0×00;
DDRC=0×00;
// Port D initialization
// Func7=In Func6=In Func5=In Func4=In Func3=In Func2=In Func1=In Func0=In
// State7=T State6=T State5=T State4=T State3=T State2=T State1=T State0=T
PORTD=0×00;
DDRD=0×00;
// Timer/Counter 0 initialization
// Clock source: System Clock
// Clock value: Timer 0 Stopped
// Mode: Normal top=0xFF
// OC0 output: Disconnected
TCCR0=0×00;
TCNT0=0×00;
OCR0=0×00;
// Timer/Counter 1 initialization
// Clock source: System Clock
// Clock value: Timer1 Stopped
// Mode: Normal top=0xFFFF
// OC1A output: Discon.
// OC1B output: Discon.
// Noise Canceler: Off
// Input Capture on Falling Edge
// Timer1 Overflow Interrupt: Off
// Input Capture Interrupt: Off
// Compare A Match Interrupt: Off
// Compare B Match Interrupt: Off
TCCR1A=0×00;
TCCR1B=0×00;
TCNT1H=0×00;
TCNT1L=0×00;
ICR1H=0×00;
ICR1L=0×00;
OCR1AH=0×00;
OCR1AL=0×00;
OCR1BH=0×00;
OCR1BL=0×00;
// Timer/Counter 2 initialization
// Clock source: System Clock
// Clock value: Timer2 Stopped
// Mode: Normal top=0xFF
// OC2 output: Disconnected
ASSR=0×00;
TCCR2=0×00;
TCNT2=0×00;
OCR2=0×00;
// External Interrupt(s) initialization
// INT0: Off
// INT1: Off
// INT2: Off
MCUCR=0×00;
MCUCSR=0×00;
// Timer(s)/Counter(s) Interrupt(s) initialization
TIMSK=0×00;
// USART initialization
// Communication Parameters: 8 Data, 1 Stop, No Parity
// USART Receiver: On
// USART Transmitter: On
// USART Mode: Asynchronous
// USART Baud Rate: 9600
UCSRA=0×00;
UCSRB=0×18;
UCSRC=0×86;
UBRRH=0×00;
UBRRL=0x4D;
// Analog Comparator initialization
// Analog Comparator: Off
// Analog Comparator Input Capture by Timer/Counter 1: Off
ACSR=0×80;
SFIOR=0×00;
// ADC initialization
// ADC disabled
ADCSRA=0×00;
// SPI initialization
// SPI disabled
SPCR=0×00;
// TWI initialization
// TWI disabled
TWCR=0×00;
// I2C Bus initialization
i2c_init();
// DS1307 Real Time Clock initialization
// Square wave output on pin SQW/OUT: On
// Square wave frequency: 1Hz
rtc_init(0,1,0);
rtc_set_date(12,12,11);
rtc_set_time(21,0,0);
while (1)
{
rtc_get_date(&tanggal_t,&bulan_t,&tahun_t);
if(tanggal_t!=tanggal||bulan_t!=bulan || tahun_t!=tahun)
{
tanggal=tanggal_t;
bulan=bulan_t;
tahun=tahun_t;
printf(“Tanggal: %d-%d-%d\n”,tanggal,bulan,tahun);
}
rtc_get_time(&jam_t,&menit_t,&detik_t);
if(jam_t!=jam||menit_t!=menit||detik_t!=detik)
{
jam=jam_t;
menit=menit_t;
detik=detik_t;
printf(“Waktu : %d:d:d\n”,jam,menit,detik);
}
};
}
untuk listing program menampilkan jam:
#include <mega16.h>
#include <delay.h>
// I2C Bus functions
#asm
.equ __i2c_port=0×15 ;PORTC
.equ __sda_bit=1
.equ __scl_bit=0
#endasm
#include <i2c.h>
// DS1307 Real Time Clock functions
#include <ds1307.h>
// Declare your global variables here
#include <delay.h>
#define data PORTB.0
#define enable PORTB.1
#define clock PORTB.2
#define clear PORTB.3
#define huruf 11
unsigned char h,m,s;
unsigned int ulang;
unsigned char kata[5 * huruf];
unsigned char buffer[50];
const unsigned char a[5] = {0b01111110, 0b00001001, 0b00001001, 0b00001001, 0b01111110},
b[5] = {0b01111111, 0b01001001, 0b01001001, 0b01001001, 0b00110110},
c[5] = {0b00111110, 0b01000001, 0b01000001, 0b01000001, 0b00100010},
d[5] = {0b01111111, 0b01000001, 0b01000001, 0b01000001, 0b00111110},
e[5] = {0b01111111, 0b01001001, 0b01001001, 0b01001001, 0b01001001},
f[5] = {0b01111111, 0b00001001, 0b00001001, 0b00001001, 0b00000001},
g[5] = {0b00111110, 0b01000001, 0b01001001, 0b01001001, 0b00110010},
//h[5] = {0b01111111, 0b00001000, 0b00001000, 0b00001000, 0b01111111},
i[5] = {0b00000000, 0b01000001, 0b01111111, 0b01000001, 0b00000000},
j[5] = {0b00100000, 0b01000000, 0b01000000, 0b01000000, 0b00111111},
k[5] = {0b01111111, 0b00001000, 0b00010100, 0b00100010, 0b01000001},
l[5] = {0b01111111, 0b01000000, 0b01000000, 0b01000000, 0b01000000},
//m[5] = {0b01111111, 0b00000010, 0b00000100, 0b00000010, 0b01111111},
n[5] = {0b01111111, 0b00000010, 0b00000100, 0b00001000, 0b01111111},
o[5] = {0b00111110, 0b01000001, 0b01000001, 0b01000001, 0b00111110},
p[5] = {0b01111111, 0b00001001, 0b00001001, 0b00001001, 0b00000110},
q[5] = {0b00111110, 0b01000001, 0b01010001, 0b01100001, 0b01111110},
r[5] = {0b01111111, 0b00001001, 0b00001001, 0b00001001, 0b01110110},
//s[5] = {0b01000110, 0b01001001, 0b01001001, 0b01001001, 0b00110001},
t[5] = {0b00000001, 0b00000001, 0b01111111, 0b00000001, 0b00000001},
u[5] = {0b00111111, 0b01000000, 0b01000000, 0b01000000, 0b00111111},
v[5] = {0b00011111, 0b00100000, 0b01000000, 0b00100000, 0b00011111},
w[5] = {0b00111111, 0b01000000, 0b00110000, 0b01000000, 0b00111111},
x[5] = {0b01100011, 0b00010100, 0b00001000, 0b00010100, 0b01100011},
y[5] = {0b00000111, 0b00001000, 0b01111000, 0b00001000, 0b00000111},
z[5] = {0b01100001, 0b01010001, 0b01001001, 0b01000101, 0b01000011},
a0[5] = {0b00111110, 0b01010001, 0b01001001, 0b01000101, 0b00111110},
a1[5] = {0b00000000, 0b01000010, 0b01111111, 0b01000000, 0b00000000},
a2[5] = {0b01000010, 0b01100001, 0b01010001, 0b01001001, 0b01000110},
a3[5] = {0b00100010, 0b01000001, 0b01001001, 0b01001001, 0b00110110},
a4[5] = {0b00010000, 0b00011000, 0b00010100, 0b00010010, 0b01111001},
a5[5] = {0b01000111, 0b01000101, 0b01000101, 0b01000101, 0b00111001},
a6[5] = {0b00111110, 0b01001001, 0b01001001, 0b01001001, 0b00110000},
a7[5] = {0b00000001, 0b00000001, 0b01111001, 0b00000101, 0b00000011},
a8[5] = {0b00110110, 0b01001001, 0b01001001, 0b01001001, 0b00110110},
a9[5] = {0b00000110, 0b01001001, 0b01001001, 0b01001001, 0b00111110},
space[5] = {0b00000000, 0b00000000, 0b00000000, 0b00000000, 0b00000000},
min[5] = {0b00000000, 0b00001000, 0b00001000, 0b00001000, 0b00000000},
longmin[5] = {0b00001000, 0b00001000, 0b00001000, 0b00001000, 0b00001000},
panah[5] = {0b00001000, 0b00001000, 0b00101010, 0b00011100, 0b00001000},
titik[5] = {0b00000000, 0b00000000, 0b01000000, 0b00000000, 0b00000000},
titik2[5] = {0b00000000, 0b00000000, 0b00010100, 0b00000000, 0b00000000},
tandaseru[5] = {0b00000110, 0b00001111, 0b01011111, 0b00001111, 0b00000110},
kurungkurawaltutup[5] = {0b01000001, 0b01000001, 0b00110110, 0b00001000, 0b00001000},
kurungkurawalbuka[5] = {0b00001000, 0b00001000, 0b00110110, 0b01000001, 0b01000001},
garisbawah[5] = {0b01000000, 0b01000000, 0b01000000, 0b01000000, 0b01000000},
caping[5] = {0b00001100, 0b00000110, 0b00000011, 0b00000110, 0b00001100},
capingbalik[5] = {0b00011000, 0b00110000, 0b01100000, 0b00110000, 0b00011000},
besar[5] = {0b01000001, 0b01100011, 0b00110110, 0b00011100, 0b00001000},
kecil[5] = {0b00001000, 0b00011100, 0b00110110, 0b01100011, 0b01000001};
void rst()
{
clear = 0;
clear = 1;
PORTA = 0b00000000;
data = 1;
for(ulang = 0; ulang < 50; ulang++)
{
clock = 1;
clock = 0;
delay_us(10);
}
}
void sft()
{
clock = 1;
clock = 0;
delay_us(100);
data = 1;
}
void tampil(unsigned int c)
{
unsigned int a, b = 0;
for(a = 0; a < c; a++)
{
rst();
data = 0;
do
{
PORTA = buffer[b];
sft();
b++;
}
while(b < 50);
b = 0;
}
}
//c:kecepatan, d & e:pada posisi d kecepatan e, f:berhenti geser pada posisi f
void kanan(unsigned int c, int d, unsigned int e, int f)
{
unsigned int a, b;
for(a = 0; a < 5 * huruf + 50; a++)
{
for(b = 49; b > 0; b–) //geser isi buffer
buffer[b] = buffer[b - 1];
if(a < (5 * huruf))
buffer[0] = kata[5 * huruf - (1 + a)];
else
buffer[0] = 0b00000000;
if(a == f)
a = 5 * huruf + 50;
if(a != d)
tampil(c);
if(a == d)
tampil(e);
}
}
//membuat semua isi buffer = 0b00000000
void clearbuffer()
{
unsigned int a;
for(a = 0; a < 50; a++)
buffer[a] = 0b00000000;
}
void main(void)
{
// Declare your local variables here
// Input/Output Ports initialization
// Port A initialization
// Func7=Out Func6=Out Func5=Out Func4=Out Func3=Out Func2=Out Func1=Out Func0=Out
// State7=0 State6=0 State5=0 State4=0 State3=0 State2=0 State1=0 State0=0
PORTA=0×00;
DDRA=0xFF;
// Port B initialization
// Func7=Out Func6=Out Func5=Out Func4=Out Func3=Out Func2=Out Func1=Out Func0=Out
// State7=0 State6=0 State5=0 State4=0 State3=0 State2=0 State1=0 State0=0
PORTB=0×00;
DDRB=0xFF;
// Port C initialization
// Func7=In Func6=In Func5=In Func4=In Func3=In Func2=In Func1=In Func0=In
// State7=T State6=T State5=T State4=T State3=T State2=T State1=T State0=T
PORTC=0×00;
DDRC=0×00;
// Port D initialization
// Func7=In Func6=In Func5=In Func4=In Func3=In Func2=In Func1=In Func0=In
// State7=T State6=T State5=T State4=T State3=T State2=T State1=T State0=T
PORTD=0×00;
DDRD=0×00;
// Timer/Counter 0 initialization
// Clock source: System Clock
// Clock value: Timer 0 Stopped
// Mode: Normal top=0xFF
// OC0 output: Disconnected
TCCR0=0×00;
TCNT0=0×00;
OCR0=0×00;
// Timer/Counter 1 initialization
// Clock source: System Clock
// Clock value: Timer1 Stopped
// Mode: Normal top=0xFFFF
// OC1A output: Discon.
// OC1B output: Discon.
// Noise Canceler: Off
// Input Capture on Falling Edge
// Timer1 Overflow Interrupt: Off
// Input Capture Interrupt: Off
// Compare A Match Interrupt: Off
// Compare B Match Interrupt: Off
TCCR1A=0×00;
TCCR1B=0×00;
TCNT1H=0×00;
TCNT1L=0×00;
ICR1H=0×00;
ICR1L=0×00;
OCR1AH=0×00;
OCR1AL=0×00;
OCR1BH=0×00;
OCR1BL=0×00;
// Timer/Counter 2 initialization
// Clock source: System Clock
// Clock value: Timer2 Stopped
// Mode: Normal top=0xFF
// OC2 output: Disconnected
ASSR=0×00;
TCCR2=0×00;
TCNT2=0×00;
OCR2=0×00;
// External Interrupt(s) initialization
// INT0: Off
// INT1: Off
// INT2: Off
MCUCR=0×00;
MCUCSR=0×00;
// Timer(s)/Counter(s) Interrupt(s) initialization
TIMSK=0×00;
// USART initialization
// USART disabled
UCSRB=0×00;
// Analog Comparator initialization
// Analog Comparator: Off
// Analog Comparator Input Capture by Timer/Counter 1: Off
ACSR=0×80;
SFIOR=0×00;
// ADC initialization
// ADC disabled
ADCSRA=0×00;
// SPI initialization
// SPI disabled
SPCR=0×00;
// TWI initialization
// TWI disabled
TWCR=0×00;
// I2C Bus initialization
i2c_init();
// DS1307 Real Time Clock initialization
// Square wave output on pin SQW/OUT: On
// Square wave frequency: 1Hz
rtc_init(0,1,0);
rtc_set_time(20,10,10);
//rtc_set_date(11, 12, 11);
/*******************/
enable = 1;
clear = 1;
clock = 0;
data = 0;
/*******************/
while (1)
{
// Place your code here
rtc_get_time(&h,&m,&s);
if(h==0)
{
for(ulang = 0; ulang < 5; ulang++)
{
kata[ulang] = a0[ulang];
kata[ulang + 5] = a0[ulang];
//kata[ulang + 10] = titik2[ulang];
//kata[ulang + 15] = a0[ulang];
//kata[ulang + 20] = a0[ulang];
//kata[ulang + 25] = a1[ulang];
//kata[ulang + 30] = e[ulang];
//kata[ulang + 35] = m[ulang];
//kata[ulang + 40] = space[ulang];
//kata[ulang + 45] = besar[ulang];
//kata[ulang + 50] = space[ulang];
}
//kanan(2, -1, 0, 5 * huruf – 1);
//tampil(2);
}
else if(h==1)
{
for(ulang = 0; ulang < 5; ulang++)
{
kata[ulang] = a0[ulang];
kata[ulang + 5] = a1[ulang];
//kata[ulang + 10] = titik2[ulang];
//kata[ulang + 15] = a0[ulang];
//kata[ulang + 20] = a1[ulang];
//kata[ulang + 25] = a1[ulang];
//kata[ulang + 30] = e[ulang];
//kata[ulang + 35] = m[ulang];
//kata[ulang + 40] = space[ulang];
//kata[ulang + 45] = besar[ulang];
//kata[ulang + 50] = space[ulang];
}
//kanan(2, -1, 0, 5 * huruf – 1);
///tampil(350);
}
else if (h==2)
{
for(ulang = 0; ulang < 5; ulang++)
{
kata[ulang] = a0[ulang];
kata[ulang + 5] = a2[ulang];
//kata[ulang + 10] = titik2[ulang];
//kata[ulang + 15] = a0[ulang];
//kata[ulang + 20] = a1[ulang];
//kata[ulang + 25] = a1[ulang];
//kata[ulang + 30] = e[ulang];
//kata[ulang + 35] = m[ulang];
//kata[ulang + 40] = space[ulang];
//kata[ulang + 45] = besar[ulang];
//kata[ulang + 50] = space[ulang];
}
}
else if (h==3)
{
for(ulang = 0; ulang < 5; ulang++)
{
kata[ulang] = a0[ulang];
kata[ulang + 5] = a3[ulang];
//kata[ulang + 10] = titik2[ulang];
//kata[ulang + 15] = a0[ulang];
//kata[ulang + 20] = a1[ulang];
//kata[ulang + 25] = a1[ulang];
//kata[ulang + 30] = e[ulang];
//kata[ulang + 35] = m[ulang];
//kata[ulang + 40] = space[ulang];
//kata[ulang + 45] = besar[ulang];
//kata[ulang + 50] = space[ulang];
}
}
else if(h==4)
{
for(ulang = 0; ulang < 5; ulang++)
{
kata[ulang] = a0[ulang];
kata[ulang + 5] = a4[ulang];
//kata[ulang + 10] = titik2[ulang];
//kata[ulang + 15] = a0[ulang];
//kata[ulang + 20] = a1[ulang];
//kata[ulang + 25] = a1[ulang];
//kata[ulang + 30] = e[ulang];
//kata[ulang + 35] = m[ulang];
//kata[ulang + 40] = space[ulang];
//kata[ulang + 45] = besar[ulang];
//kata[ulang + 50] = space[ulang];
}
}
else if(h==5)
{
for(ulang = 0; ulang < 5; ulang++)
{
kata[ulang] = a0[ulang];
kata[ulang + 5] = a5[ulang];
}
}
else if(h==6)
{
for(ulang = 0; ulang < 5; ulang++)
{
kata[ulang] = a0[ulang];
kata[ulang + 5] = a6[ulang];
}
}
else if(h==7)
{
for(ulang = 0; ulang < 5; ulang++)
{
kata[ulang] = a0[ulang];
kata[ulang + 5] = a6[ulang];
}
}
else if(h==8)
{
for(ulang = 0; ulang < 5; ulang++)
{
kata[ulang] = a0[ulang];
kata[ulang + 5] = a6[ulang];
}
}
else if(h==9)
{
for(ulang = 0; ulang < 5; ulang++)
{
kata[ulang] = a0[ulang];
kata[ulang + 5] = a6[ulang];
}
}
else if(h==10)
{
for(ulang = 0; ulang < 5; ulang++)
{
kata[ulang] = a0[ulang];
kata[ulang + 5] = a6[ulang];
}
}
else if(h==11)
{
for(ulang = 0; ulang < 5; ulang++)
{
kata[ulang] = a0[ulang];
kata[ulang + 5] = a6[ulang];
}
}
else if(h==12)
{
for(ulang = 0; ulang < 5; ulang++)
{
kata[ulang] = a0[ulang];
kata[ulang + 5] = a6[ulang];
}
}
else if(h==13)
{
for(ulang = 0; ulang < 5; ulang++)
{
kata[ulang] = a0[ulang];
kata[ulang + 5] = a6[ulang];
}
}
else if(h==14)
{
for(ulang = 0; ulang < 5; ulang++)
{
kata[ulang] = a0[ulang];
kata[ulang + 5] = a6[ulang];
}
}
else if(h==15)
{
for(ulang = 0; ulang < 5; ulang++)
{
kata[ulang] = a0[ulang];
kata[ulang + 5] = a6[ulang];
}
}
else if(h==16)
{
for(ulang = 0; ulang < 5; ulang++)
{
kata[ulang] = a0[ulang];
kata[ulang + 5] = a6[ulang];
}
}
else if(h==17)
{
for(ulang = 0; ulang < 5; ulang++)
{
kata[ulang] = a0[ulang];
kata[ulang + 5] = a6[ulang];
}
}
else if(h==18)
{
for(ulang = 0; ulang < 5; ulang++)
{
kata[ulang] = a0[ulang];
kata[ulang + 5] = a6[ulang];
}
}
else if(h==19)
{
for(ulang = 0; ulang < 5; ulang++)
{
kata[ulang] = a0[ulang];
kata[ulang + 5] = a6[ulang];
}
}
else if(h==20)
{
for(ulang = 0; ulang < 5; ulang++)
{
kata[ulang] = a0[ulang];
kata[ulang + 5] = a6[ulang];
}
}
else if(h==21)
{
for(ulang = 0; ulang < 5; ulang++)
{
kata[ulang] = a0[ulang];
kata[ulang + 5] = a6[ulang];
}
}
//dst,,,
};
}
#include <delay.h>
// I2C Bus functions
#asm
.equ __i2c_port=0×15 ;PORTC
.equ __sda_bit=1
.equ __scl_bit=0
#endasm
#include <i2c.h>
// DS1307 Real Time Clock functions
#include <ds1307.h>
// Declare your global variables here
#include <delay.h>
#define data PORTB.0
#define enable PORTB.1
#define clock PORTB.2
#define clear PORTB.3
#define huruf 11
unsigned char h,m,s;
unsigned int ulang;
unsigned char kata[5 * huruf];
unsigned char buffer[50];
const unsigned char a[5] = {0b01111110, 0b00001001, 0b00001001, 0b00001001, 0b01111110},
b[5] = {0b01111111, 0b01001001, 0b01001001, 0b01001001, 0b00110110},
c[5] = {0b00111110, 0b01000001, 0b01000001, 0b01000001, 0b00100010},
d[5] = {0b01111111, 0b01000001, 0b01000001, 0b01000001, 0b00111110},
e[5] = {0b01111111, 0b01001001, 0b01001001, 0b01001001, 0b01001001},
f[5] = {0b01111111, 0b00001001, 0b00001001, 0b00001001, 0b00000001},
g[5] = {0b00111110, 0b01000001, 0b01001001, 0b01001001, 0b00110010},
//h[5] = {0b01111111, 0b00001000, 0b00001000, 0b00001000, 0b01111111},
i[5] = {0b00000000, 0b01000001, 0b01111111, 0b01000001, 0b00000000},
j[5] = {0b00100000, 0b01000000, 0b01000000, 0b01000000, 0b00111111},
k[5] = {0b01111111, 0b00001000, 0b00010100, 0b00100010, 0b01000001},
l[5] = {0b01111111, 0b01000000, 0b01000000, 0b01000000, 0b01000000},
//m[5] = {0b01111111, 0b00000010, 0b00000100, 0b00000010, 0b01111111},
n[5] = {0b01111111, 0b00000010, 0b00000100, 0b00001000, 0b01111111},
o[5] = {0b00111110, 0b01000001, 0b01000001, 0b01000001, 0b00111110},
p[5] = {0b01111111, 0b00001001, 0b00001001, 0b00001001, 0b00000110},
q[5] = {0b00111110, 0b01000001, 0b01010001, 0b01100001, 0b01111110},
r[5] = {0b01111111, 0b00001001, 0b00001001, 0b00001001, 0b01110110},
//s[5] = {0b01000110, 0b01001001, 0b01001001, 0b01001001, 0b00110001},
t[5] = {0b00000001, 0b00000001, 0b01111111, 0b00000001, 0b00000001},
u[5] = {0b00111111, 0b01000000, 0b01000000, 0b01000000, 0b00111111},
v[5] = {0b00011111, 0b00100000, 0b01000000, 0b00100000, 0b00011111},
w[5] = {0b00111111, 0b01000000, 0b00110000, 0b01000000, 0b00111111},
x[5] = {0b01100011, 0b00010100, 0b00001000, 0b00010100, 0b01100011},
y[5] = {0b00000111, 0b00001000, 0b01111000, 0b00001000, 0b00000111},
z[5] = {0b01100001, 0b01010001, 0b01001001, 0b01000101, 0b01000011},
a0[5] = {0b00111110, 0b01010001, 0b01001001, 0b01000101, 0b00111110},
a1[5] = {0b00000000, 0b01000010, 0b01111111, 0b01000000, 0b00000000},
a2[5] = {0b01000010, 0b01100001, 0b01010001, 0b01001001, 0b01000110},
a3[5] = {0b00100010, 0b01000001, 0b01001001, 0b01001001, 0b00110110},
a4[5] = {0b00010000, 0b00011000, 0b00010100, 0b00010010, 0b01111001},
a5[5] = {0b01000111, 0b01000101, 0b01000101, 0b01000101, 0b00111001},
a6[5] = {0b00111110, 0b01001001, 0b01001001, 0b01001001, 0b00110000},
a7[5] = {0b00000001, 0b00000001, 0b01111001, 0b00000101, 0b00000011},
a8[5] = {0b00110110, 0b01001001, 0b01001001, 0b01001001, 0b00110110},
a9[5] = {0b00000110, 0b01001001, 0b01001001, 0b01001001, 0b00111110},
space[5] = {0b00000000, 0b00000000, 0b00000000, 0b00000000, 0b00000000},
min[5] = {0b00000000, 0b00001000, 0b00001000, 0b00001000, 0b00000000},
longmin[5] = {0b00001000, 0b00001000, 0b00001000, 0b00001000, 0b00001000},
panah[5] = {0b00001000, 0b00001000, 0b00101010, 0b00011100, 0b00001000},
titik[5] = {0b00000000, 0b00000000, 0b01000000, 0b00000000, 0b00000000},
titik2[5] = {0b00000000, 0b00000000, 0b00010100, 0b00000000, 0b00000000},
tandaseru[5] = {0b00000110, 0b00001111, 0b01011111, 0b00001111, 0b00000110},
kurungkurawaltutup[5] = {0b01000001, 0b01000001, 0b00110110, 0b00001000, 0b00001000},
kurungkurawalbuka[5] = {0b00001000, 0b00001000, 0b00110110, 0b01000001, 0b01000001},
garisbawah[5] = {0b01000000, 0b01000000, 0b01000000, 0b01000000, 0b01000000},
caping[5] = {0b00001100, 0b00000110, 0b00000011, 0b00000110, 0b00001100},
capingbalik[5] = {0b00011000, 0b00110000, 0b01100000, 0b00110000, 0b00011000},
besar[5] = {0b01000001, 0b01100011, 0b00110110, 0b00011100, 0b00001000},
kecil[5] = {0b00001000, 0b00011100, 0b00110110, 0b01100011, 0b01000001};
void rst()
{
clear = 0;
clear = 1;
PORTA = 0b00000000;
data = 1;
for(ulang = 0; ulang < 50; ulang++)
{
clock = 1;
clock = 0;
delay_us(10);
}
}
void sft()
{
clock = 1;
clock = 0;
delay_us(100);
data = 1;
}
void tampil(unsigned int c)
{
unsigned int a, b = 0;
for(a = 0; a < c; a++)
{
rst();
data = 0;
do
{
PORTA = buffer[b];
sft();
b++;
}
while(b < 50);
b = 0;
}
}
//c:kecepatan, d & e:pada posisi d kecepatan e, f:berhenti geser pada posisi f
void kanan(unsigned int c, int d, unsigned int e, int f)
{
unsigned int a, b;
for(a = 0; a < 5 * huruf + 50; a++)
{
for(b = 49; b > 0; b–) //geser isi buffer
buffer[b] = buffer[b - 1];
if(a < (5 * huruf))
buffer[0] = kata[5 * huruf - (1 + a)];
else
buffer[0] = 0b00000000;
if(a == f)
a = 5 * huruf + 50;
if(a != d)
tampil(c);
if(a == d)
tampil(e);
}
}
//membuat semua isi buffer = 0b00000000
void clearbuffer()
{
unsigned int a;
for(a = 0; a < 50; a++)
buffer[a] = 0b00000000;
}
void main(void)
{
// Declare your local variables here
// Input/Output Ports initialization
// Port A initialization
// Func7=Out Func6=Out Func5=Out Func4=Out Func3=Out Func2=Out Func1=Out Func0=Out
// State7=0 State6=0 State5=0 State4=0 State3=0 State2=0 State1=0 State0=0
PORTA=0×00;
DDRA=0xFF;
// Port B initialization
// Func7=Out Func6=Out Func5=Out Func4=Out Func3=Out Func2=Out Func1=Out Func0=Out
// State7=0 State6=0 State5=0 State4=0 State3=0 State2=0 State1=0 State0=0
PORTB=0×00;
DDRB=0xFF;
// Port C initialization
// Func7=In Func6=In Func5=In Func4=In Func3=In Func2=In Func1=In Func0=In
// State7=T State6=T State5=T State4=T State3=T State2=T State1=T State0=T
PORTC=0×00;
DDRC=0×00;
// Port D initialization
// Func7=In Func6=In Func5=In Func4=In Func3=In Func2=In Func1=In Func0=In
// State7=T State6=T State5=T State4=T State3=T State2=T State1=T State0=T
PORTD=0×00;
DDRD=0×00;
// Timer/Counter 0 initialization
// Clock source: System Clock
// Clock value: Timer 0 Stopped
// Mode: Normal top=0xFF
// OC0 output: Disconnected
TCCR0=0×00;
TCNT0=0×00;
OCR0=0×00;
// Timer/Counter 1 initialization
// Clock source: System Clock
// Clock value: Timer1 Stopped
// Mode: Normal top=0xFFFF
// OC1A output: Discon.
// OC1B output: Discon.
// Noise Canceler: Off
// Input Capture on Falling Edge
// Timer1 Overflow Interrupt: Off
// Input Capture Interrupt: Off
// Compare A Match Interrupt: Off
// Compare B Match Interrupt: Off
TCCR1A=0×00;
TCCR1B=0×00;
TCNT1H=0×00;
TCNT1L=0×00;
ICR1H=0×00;
ICR1L=0×00;
OCR1AH=0×00;
OCR1AL=0×00;
OCR1BH=0×00;
OCR1BL=0×00;
// Timer/Counter 2 initialization
// Clock source: System Clock
// Clock value: Timer2 Stopped
// Mode: Normal top=0xFF
// OC2 output: Disconnected
ASSR=0×00;
TCCR2=0×00;
TCNT2=0×00;
OCR2=0×00;
// External Interrupt(s) initialization
// INT0: Off
// INT1: Off
// INT2: Off
MCUCR=0×00;
MCUCSR=0×00;
// Timer(s)/Counter(s) Interrupt(s) initialization
TIMSK=0×00;
// USART initialization
// USART disabled
UCSRB=0×00;
// Analog Comparator initialization
// Analog Comparator: Off
// Analog Comparator Input Capture by Timer/Counter 1: Off
ACSR=0×80;
SFIOR=0×00;
// ADC initialization
// ADC disabled
ADCSRA=0×00;
// SPI initialization
// SPI disabled
SPCR=0×00;
// TWI initialization
// TWI disabled
TWCR=0×00;
// I2C Bus initialization
i2c_init();
// DS1307 Real Time Clock initialization
// Square wave output on pin SQW/OUT: On
// Square wave frequency: 1Hz
rtc_init(0,1,0);
rtc_set_time(20,10,10);
//rtc_set_date(11, 12, 11);
/*******************/
enable = 1;
clear = 1;
clock = 0;
data = 0;
/*******************/
while (1)
{
// Place your code here
rtc_get_time(&h,&m,&s);
if(h==0)
{
for(ulang = 0; ulang < 5; ulang++)
{
kata[ulang] = a0[ulang];
kata[ulang + 5] = a0[ulang];
//kata[ulang + 10] = titik2[ulang];
//kata[ulang + 15] = a0[ulang];
//kata[ulang + 20] = a0[ulang];
//kata[ulang + 25] = a1[ulang];
//kata[ulang + 30] = e[ulang];
//kata[ulang + 35] = m[ulang];
//kata[ulang + 40] = space[ulang];
//kata[ulang + 45] = besar[ulang];
//kata[ulang + 50] = space[ulang];
}
//kanan(2, -1, 0, 5 * huruf – 1);
//tampil(2);
}
else if(h==1)
{
for(ulang = 0; ulang < 5; ulang++)
{
kata[ulang] = a0[ulang];
kata[ulang + 5] = a1[ulang];
//kata[ulang + 10] = titik2[ulang];
//kata[ulang + 15] = a0[ulang];
//kata[ulang + 20] = a1[ulang];
//kata[ulang + 25] = a1[ulang];
//kata[ulang + 30] = e[ulang];
//kata[ulang + 35] = m[ulang];
//kata[ulang + 40] = space[ulang];
//kata[ulang + 45] = besar[ulang];
//kata[ulang + 50] = space[ulang];
}
//kanan(2, -1, 0, 5 * huruf – 1);
///tampil(350);
}
else if (h==2)
{
for(ulang = 0; ulang < 5; ulang++)
{
kata[ulang] = a0[ulang];
kata[ulang + 5] = a2[ulang];
//kata[ulang + 10] = titik2[ulang];
//kata[ulang + 15] = a0[ulang];
//kata[ulang + 20] = a1[ulang];
//kata[ulang + 25] = a1[ulang];
//kata[ulang + 30] = e[ulang];
//kata[ulang + 35] = m[ulang];
//kata[ulang + 40] = space[ulang];
//kata[ulang + 45] = besar[ulang];
//kata[ulang + 50] = space[ulang];
}
}
else if (h==3)
{
for(ulang = 0; ulang < 5; ulang++)
{
kata[ulang] = a0[ulang];
kata[ulang + 5] = a3[ulang];
//kata[ulang + 10] = titik2[ulang];
//kata[ulang + 15] = a0[ulang];
//kata[ulang + 20] = a1[ulang];
//kata[ulang + 25] = a1[ulang];
//kata[ulang + 30] = e[ulang];
//kata[ulang + 35] = m[ulang];
//kata[ulang + 40] = space[ulang];
//kata[ulang + 45] = besar[ulang];
//kata[ulang + 50] = space[ulang];
}
}
else if(h==4)
{
for(ulang = 0; ulang < 5; ulang++)
{
kata[ulang] = a0[ulang];
kata[ulang + 5] = a4[ulang];
//kata[ulang + 10] = titik2[ulang];
//kata[ulang + 15] = a0[ulang];
//kata[ulang + 20] = a1[ulang];
//kata[ulang + 25] = a1[ulang];
//kata[ulang + 30] = e[ulang];
//kata[ulang + 35] = m[ulang];
//kata[ulang + 40] = space[ulang];
//kata[ulang + 45] = besar[ulang];
//kata[ulang + 50] = space[ulang];
}
}
else if(h==5)
{
for(ulang = 0; ulang < 5; ulang++)
{
kata[ulang] = a0[ulang];
kata[ulang + 5] = a5[ulang];
}
}
else if(h==6)
{
for(ulang = 0; ulang < 5; ulang++)
{
kata[ulang] = a0[ulang];
kata[ulang + 5] = a6[ulang];
}
}
else if(h==7)
{
for(ulang = 0; ulang < 5; ulang++)
{
kata[ulang] = a0[ulang];
kata[ulang + 5] = a6[ulang];
}
}
else if(h==8)
{
for(ulang = 0; ulang < 5; ulang++)
{
kata[ulang] = a0[ulang];
kata[ulang + 5] = a6[ulang];
}
}
else if(h==9)
{
for(ulang = 0; ulang < 5; ulang++)
{
kata[ulang] = a0[ulang];
kata[ulang + 5] = a6[ulang];
}
}
else if(h==10)
{
for(ulang = 0; ulang < 5; ulang++)
{
kata[ulang] = a0[ulang];
kata[ulang + 5] = a6[ulang];
}
}
else if(h==11)
{
for(ulang = 0; ulang < 5; ulang++)
{
kata[ulang] = a0[ulang];
kata[ulang + 5] = a6[ulang];
}
}
else if(h==12)
{
for(ulang = 0; ulang < 5; ulang++)
{
kata[ulang] = a0[ulang];
kata[ulang + 5] = a6[ulang];
}
}
else if(h==13)
{
for(ulang = 0; ulang < 5; ulang++)
{
kata[ulang] = a0[ulang];
kata[ulang + 5] = a6[ulang];
}
}
else if(h==14)
{
for(ulang = 0; ulang < 5; ulang++)
{
kata[ulang] = a0[ulang];
kata[ulang + 5] = a6[ulang];
}
}
else if(h==15)
{
for(ulang = 0; ulang < 5; ulang++)
{
kata[ulang] = a0[ulang];
kata[ulang + 5] = a6[ulang];
}
}
else if(h==16)
{
for(ulang = 0; ulang < 5; ulang++)
{
kata[ulang] = a0[ulang];
kata[ulang + 5] = a6[ulang];
}
}
else if(h==17)
{
for(ulang = 0; ulang < 5; ulang++)
{
kata[ulang] = a0[ulang];
kata[ulang + 5] = a6[ulang];
}
}
else if(h==18)
{
for(ulang = 0; ulang < 5; ulang++)
{
kata[ulang] = a0[ulang];
kata[ulang + 5] = a6[ulang];
}
}
else if(h==19)
{
for(ulang = 0; ulang < 5; ulang++)
{
kata[ulang] = a0[ulang];
kata[ulang + 5] = a6[ulang];
}
}
else if(h==20)
{
for(ulang = 0; ulang < 5; ulang++)
{
kata[ulang] = a0[ulang];
kata[ulang + 5] = a6[ulang];
}
}
else if(h==21)
{
for(ulang = 0; ulang < 5; ulang++)
{
kata[ulang] = a0[ulang];
kata[ulang + 5] = a6[ulang];
}
}
//dst,,,
};
}
kendala yang dihadapi:
1. Kurangnya ketelitian dalam menggambar menggunakan orcad sehingga PCB yang dicetak tidak sesuai dengan yang diharapkan sehingga saya mengambil keputusan untuk menyolder secara manual.
2. Dikarenakan arus yang digunakan untuk dotmatrix menggunakan sumber dari 7805 secara langsung dan rangkaiannya di solder manual maka arus yang dikeluarkan tidak mencukupi kebutuhan dot matrix sehingga nyala dot matrix menjadi redup.
3. Karena arus yang melalui dotmatrix kecil maka program yang dibuat tidak bisa dijalankan
solusi:
1. Lebih Teliti dalam membuat layout.
2. Jika arus yang ddikeluarkan kecil maka sebaiknya ditambahkan penguat arus setelah rangkaian 7805.
0 komentar:
Posting Komentar