Code Quet Ban Phim4x4 Hien Thi LCD

You might also like

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

#include<16f877a.

h>

#use delay(crystal=20m)

//thiet lap lcd

#define LCD_RS_PIN PIN_C0

#define LCD_RW_PIN PIN_C1

#define LCD_ENABLE_PIN PIN_C2

#define LCD_DATA4_PIN PIN_C3

#define LCD_DATA5_PIN PIN_C4

#define LCD_DATA6_PIN PIN_C5

#define LCD_DATA7_PIN PIN_C6

#include<lcd.c>

void main()

//thiet lap i/o cho vdk

lcd_init();//khoi dong lcd

lcd_putc('f');//xóa man hinh lcd

lcd_gotoxy(2,1);//di toi hang 1 cot 1

lcd_putc("ban phim quet");

set_tris_d(0x0f);

int i=0;

while(true)

{ //quetcot 1

output_low(pin_d4);
output_high(pin_d5);

output_high(pin_d6);

output_high(pin_d7);

//ktra hang

if(input(pin_d0)==0)

i=0;

if(input(pin_d1)==0)

i=1;

if(input(pin_d2)==0)

i=2;

if(input(pin_d3)==0)

i=3;

//quetcot2

output_high(pin_d4);

output_low(pin_d5);

//ktra hang

if(input(pin_d0)==0)

i=4;

if(input(pin_d1)==0)

i=5;

if(input(pin_d2)==0)

i=6;

if(input(pin_d3)==0)

i=7;

//quetcot3
output_high(pin_d5);

output_low(pin_d6);

//ktra hang

if(input(pin_d0)==0)

i=8;

if(input(pin_d1)==0)

i=9;

if(input(pin_d2)==0)

i=10;

if(input(pin_d3)==0)

i=11;

//quetcot4

output_high(pin_d6);

output_low(pin_d7);

//ktra hang

if(input(pin_d0)==0)

i=12;

if(input(pin_d1)==0)

i=13;

if(input(pin_d2)==0)

i=14;

if(input(pin_d3)==0)

i=15;

lcd_gotoxy(7,2);
printf(lcd_putc,"%2u",i);

You might also like