Dien Tro 330 Om

You might also like

Download as doc, pdf, or txt
Download as doc, pdf, or txt
You are on page 1of 4

U1 U2 dien tro 330 Om

13 33 3 2
OSC1/CLKIN RB0/INT D0 Q0
14 34 4 5
OSC2/CLKOUT RB1 D1 Q1
35 7 6
RB2 D2 Q2
2 36 8 9
RA0/AN0 RB3/PGM D3 Q3
3 37 13 12
RA1/AN1 RB4 D4 Q4
4 38 14 15
RA2/AN2/VREF-/CVREF RB5 D5 Q5
5 39 17 16
RA3/AN3/VREF+ RB6/PGC D6 Q6
6 40 18 19
RA4/T0CKI/C1OUT RB7/PGD D7 Q7
7
RA5/AN4/SS/C2OUT
15 1
RC0/T1OSO/T1CKI OE
8 16 11
RE0/AN5/RD RC1/T1OSI/CCP2 LE
9 17
RE1/AN6/WR RC2/CCP1
10 18 74LS373
RE2/AN7/CS RC3/SCK/SCL
23
RC4/SDI/SDA
1 24
MCLR/Vpp/THV RC5/SDO
25
RC6/TX/CK
26
RC7/RX/DT
19
RD0/PSP0
20
RD1/PSP1
21
RD2/PSP2
22 U3
RD3/PSP3
27 3 2
RD4/PSP4 D0 Q0
28 4 5
RD5/PSP5 D1 Q1
29 7 6
RD6/PSP6 D2 Q2
30 8 9
RD7/PSP7 D3 Q3
13 12
D4 Q4
PIC16F877A 14 15
D5 Q5
17 16
D6 Q6
18 19
D7 Q7
1
OE
11
LE
74LS373

D2 D5

LED-RED LED-RED
D1 D6

LED-GREEN LED-GREEN
D3 D8

LED-YELLOW LED-YELLOW
D7
D4

LED-BLUE
LED-BLUE

#include <16F877A.h>

//#device 18F4680*=16 ADC=10

#fuses NOWDT,PUT,XT,NOPROTECT

#use delay(clock=4000000)

#use fast_io(c)

#byte portc=0x07

int16 count;

unsigned int8 giay=0,n;

unsigned int8 const


so[32]={0x92,0x99,0xb0,0xa4,0xf9,0xc0,0x90,0x80,0xf8,0x82,0x92,0x99,0xb0,0xa4,0xf9,0xc0,0x92,0x99,
0xb0,0xa4,0xf9,0xc0,0x90,0x80,0xf8,0x82,0x92,0x99,0xb0,0xa4,0xf9,0xc0};
unsigned int8 const
chuc[32]={0xF9,0xF9,0xF9,0xF9,0xF9,0xf9,0xC0,0xC0,0xC0,0xC0,0xC0,0xC0,0xC0,0xC0,0xC0,0xC0,0xF9,0x
F9,0xF9,0xF9,0xF9,0xf9,0xC0,0xC0,0xC0,0xC0,0xC0,0xC0,0xC0,0xC0,0xC0,0xC0};

void hienthi(n){

output_b(so[n]);

output_high(pin_c1);

output_low(pin_c1);

output_b(chuc[n]);

output_high(pin_c0);

output_low(pin_c0);

//Chuong trinh ngat TMR0

#int_timer0

void timer0()

set_timer0(56); // T = 2*(256 - 56)*1us = 400us (n?u dùng th?ch anh 20M thi thay 1us thành 0,2us)

++count;

if(count == 2500) // 2500*400us = 1000000us = 1s

count=0;

//if(giay==32) {output_high(pin_d0);output_high(pin_d5);hienthi(32);}

if(giay==31) {output_d(0b00101001);hienthi(31);}

if(giay==30) {output_d(0b00101001);hienthi(30);}

if(giay==29) {output_d(0b00101001);hienthi(29);}

if(giay==28) {output_d(0b00101001);hienthi(28);}

if(giay==27) {output_d(0b00101001);hienthi(27);}
if(giay==26) {output_d(0b00101001);hienthi(26);}

if(giay==25) {output_d(0b00101001);hienthi(25);}

if(giay==24) {output_d(0b00101001);hienthi(24);}

if(giay==23) {output_d(0b00101001);hienthi(23);}

if(giay==22) {output_d(0b00101001);hienthi(22);}

if(giay==21) {output_d(0b00101001);hienthi(21);}

if(giay==20) {output_d(0b00101001);hienthi(20);}

if(giay==19) {output_d(0b00101001);hienthi(19);}

if(giay==18) {output_d(0b01001001);hienthi(18);}

if(giay==17) {output_d(0b01001001);hienthi(17);}

if(giay==16) {output_d(0b01001001);hienthi(16);}

if(giay==15) {output_d(0b10010010);hienthi(15);}

if(giay==14) {output_d(0b10010010);hienthi(14);}

if(giay==13) {output_d(0b10010010);hienthi(13);}

if(giay==12) {output_d(0b10010010);hienthi(12);}

if(giay==11) {output_d(0b10010010);hienthi(11);}

if(giay==10) {output_d(0b10010010);hienthi(10);}

if(giay==9) {output_d(0b10010010);hienthi(9);}

if(giay==8) {output_d(0b10010010);hienthi(8);}

if(giay==7) {output_d(0b10010010);hienthi(7);}

if(giay==6) {output_d(0b10010010);hienthi(6);}

if(giay==5) {output_d(0b10010010);hienthi(5);}

if(giay==4) {output_d(0b10010010);hienthi(4);}

if(giay==3) {output_d(0b10010010);hienthi(3);}

if(giay==2) {output_d(0b10010100);hienthi(2);}
if(giay==1) {output_d(0b10010100);hienthi(1);}

if(giay==0) {output_d(0b10010100);hienthi(0);}

giay+=1;

if(giay==31) giay=0;

//Chuong trinh dich led

void main()

{ set_tris_c(0);

while (1){

enable_interrupts(int_timer0);

setup_timer_0(RTCC_INTERNAL|RTCC_DIV_2);

enable_interrupts(global);

}}

You might also like