0% found this document useful (0 votes)
8 views12 pages

WWW

Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
8 views12 pages

WWW

Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 12

1.

20

#include <16F877A.h>

#fuses HS

#use delay(clock=8M)

#include <lcd.c>

void main (void)

lcd_init();

lcd_gotoxy(1,1);

printf(lcd_putc,"Welcome to");

delay_ms(3);

lcd_gotoxy(1,2);

printf(lcd_putc,"*****HUTECH*****");

delay_ms(3);

while(1);

}
LCD1
LM016L

U1
13 33
OSC1/CLKIN RB0/INT

VDD
VSS

VEE
14 34

RW
RS

D0
D1
D2
D3
D4
D5
D6
D7
OSC2/CLKOUT RB1

E
35
RB2
2 36
RA0/AN0 RB3/PGM

1
2
3

4
RW 5
6

7
8
9
10
11
LD5 12
LD6 13
LD7 14
3 37

LD4
RA1/AN1 RB4
4 38
RA2/AN2/VREF-/CVREF RB5

EN
RS
5 39
RA3/AN3/VREF+ RB6/PGC
6 40
RA4/T0CKI/C1OUT RB7/PGD
7
RA5/AN4/SS/C2OUT
15
RC0/T1OSO/T1CKI
8 16
RE0/AN5/RD RC1/T1OSI/CCP2
9 17
RE1/AN6/W R RC2/CCP1
10 18 RC3
RE2/AN7/CS RC3/SCK/SCL
23 RC4
RC4/SDI/SDA
1 24
MCLR/Vpp/THV RC5/SDO
25
RC6/TX/CK
26
RC7/RX/DT
19 EN
RD0/PSP0
20 RS
RD1/PSP1
RD2/PSP2
21 RW R1 R2
22 10k 10k
RD3/PSP3
27 LD4
RD4/PSP4
28 Ld5
RD5/PSP5
29 LD6
RD6/PSP6
30 LD7
RD7/PSP7
PIC16F877A
SW1
RC3

SW2
RC4

1.21

#include <16F877A.h>

#fuses HS

#use delay(clock=8M)

#include <lcd.c>

void main (void)

int8 dem;

lcd_init();

set_tris_d(0x00);

output_d(0x00);
lcd_init();

dem=0;

lcd_gotoxy(1,1);

printf(lcd_putc,"Counter");

delay_ms(3);

while(1)

lcd_gotoxy(10,2);

printf(lcd_putc,"%03u",dem);

delay_ms(300);

dem++;

if(dem==100)

break;

1.22

#include <16F877A.h>

#fuses NOWDT, HS, NOPUT, NOPROTECT, NODEBUG, NOBROWNOUT, NOLVP

#use delay(clock=8M)

#include <lcd.c>

#define SW1 PIN_C3

#define SW2 PIN_C4

void main (void)

{
lcd_init();

set_tris_d(0x00);

output_d(0x00);

While(1)

if (!input(SW1))

lcd_gotoxy(1,1);

printf(lcd_putc,"Xin chao cac ban!");

delay_ms(3);

lcd_gotoxy(10,2);

printf(lcd_putc," "); delay_ms(3);

if (!input(SW2))

lcd_gotoxy(10,2);

printf(lcd_putc,"HUTECH");

delay_ms(3);

lcd_gotoxy(1,1);

printf(lcd_putc," "); delay_ms(3);


}

1.23

#include <16F877A.h>

#fuses NOWDT, HS, NOPUT, NOPROTECT, NODEBUG, NOBROWNOUT, NOLVP

#use delay(clock=8M)

#include <lcd.c>

#define SW1 PIN_C3

#define SW2 PIN_C4

void main (void)

int8 set_val;

set_tris_d(0x00);

lcd_init();

output_d(0x00);

set_val=0;

lcd_gotoxy(5,1);

printf(lcd_putc,"Set value:");

while(1)

if(!input(SW1))

{
if(( set_val <200) && ( set_val!=195))

set_val+=10 ;

lcd_gotoxy(8,2);

printf(lcd_putc,"%03u",set_val);

delay_ms(400);

if(!input(SW2))

if(set_val>0)

set_val-=5;

lcd_gotoxy(8,2);

printf(lcd_putc,"%03u",set_val);

delay_ms(400);

}
}

1.24

#include <16F877A.h>

#fuses NOWDT, HS, NOPUT, NOPROTECT, NODEBUG, NOBROWNOUT, NOLVP

#use delay(clock=8M)

#include <lcd.c>

#define SW1 PIN_C3

#define SW2 PIN_C4

void main (void)

int8 g,ptg;

g=0;

ptg=0;

int8 i,j,dem;

set_tris_d(0x00);

lcd_init();

output_d(0x00);

lcd_gotoxy(1,1);

printf(lcd_putc,"DONG HO DEM GIAY");

lcd_gotoxy(4,2);

printf(lcd_putc,"%02u:%02u",g,ptg);
while(1)

if(!input(SW1))

while(1)

ptg++;

if(ptg==100)

ptg=0;

g++;

if(g==60)

g=0;

ptg=0;

lcd_gotoxy(4,2);

printf(lcd_putc,"%02u:%02u",g,ptg);

delay_ms(10);

if(!input(SW2))
break;

if(!input(SW2))

delay_ms(100);

dem++;

if (dem>=50)

lcd_gotoxy(4,2);

printf(lcd_putc,"00:00");

i=0;

j=0;

dem=0;

else

dem=0;

}
1.25

#include <16F877A.h>

#fuses NOWDT, HS, NOPUT, NOPROTECT, NODEBUG, NOBROWNOUT, NOLVP

#use delay(clock=8M)

#include <lcd.c>

#define SW1 PIN_C3

#define SW2 PIN_C4

int8 SW = 0;

int8 gio = 0, phut = 0, ptgiay = 0;

void delay_with_check(int time_ms) {

for (int t = 0; t < time_ms / 10; t++) {

delay_ms(30);

if (!input(SW1)) SW = 1;

if (!input(SW2)) SW = 2;

void main() {

lcd_init();

lcd_gotoxy(4, 1);

printf(lcd_putc, "DONG HO");

while (TRUE) {

lcd_gotoxy(4, 2);
printf(lcd_putc, "%02u:%02u:%02u", gio, phut, ptgiay);

if (SW == 1) {

while (!input(SW1));

gio = (gio + 1) % 24;

SW = 0;

if (SW == 2) {

while (!input(SW2));

phut = (phut + 1) % 60;

SW = 0;

delay_with_check(1000);

ptgiay++;

if (ptgiay >= 60) {

ptgiay = 0;

phut++;

if (phut >= 60) {

phut = 0;

gio++;

if (gio >= 24) {

gio = 0;

}
}

You might also like