PIC Vietnam

Go Back   PIC Vietnam > Các Đề Tài > Luận văn tốt nghiệp

Tài trợ cho PIC Vietnam
Trang chủ Đăng Kí Hỏi/Ðáp Thành Viên Lịch Tìm Kiếm Bài Trong Ngày Ðánh Dấu Ðã Ðọc Vi điều khiển

Luận văn tốt nghiệp Nếu bạn thắc mắc vì sao chúng tôi muốn phổ biến các luận văn tốt nghiệp? Xin xem tại đây

 
 
Ðiều Chỉnh Xếp Bài
Prev Previous Post   Next Post Next
Old 08-07-2014, 02:30 AM   #1
onghatbekacdvn
Nhập môn đệ tử
 
Tham gia ngày: Jul 2014
Bài gửi: 2
:
Giao tiếp nút nhấn với LCD....

Mọi người ơi giúp em giao tiếp nút nhấn với...đề tài của mình là đọc nhiệt độ bằng DS18B20 và hiển thị nhiệt độ lên LCD và khi nhiệt độ đạt tới mức mà mình quy định trong code thì còi buzzer sẽ hú báo động...Nhưng bây h mình muốn từ phần cứng mình nhấn nút nhấn thì nhiệt độ báo cháy sẽ tăng hoặc giảm...VD: trong chương trình mình viết nhiệt độ báo cháy bằng 34 vậy khi nhiệt độ môi trường đạt tới 34 độ thì còi sẽ hú....vậy bây giờ phải viết code cho nút nhấn ntn để tăng hoặc giảm nhiệt độ báo cháy đó mà không cần phải chỉnh sửa trong code
....Mọi người giúp em với nha...Tuần sau là em phải báo cáo rùi...Đồ Án Tốt Nghiệp of E...hjx
Còn đây là code:
#include <16F877a.h>
#include <def_877a.h>
#FUSES NOWDT, HS, NOPUT, NOPROTECT, NODEBUG, NOBROWNOUT,NOLVP, NOCPD, NOWRT
#use delay(clock=20000000)
#include "1wire.c"

#define RS PIN_A1
#define RW PIN_A2
#define E PIN_A3


#byte portB=0x06
#byte portC=0x07
#byte portD=0x08
#byte portE=0x09


#define DS18B20_C
#define Buzz PIN_E2
#define button PIN_E0
int t=33;
float nhietdo;
float ds18b20_read();

float ds18b20_read()
{
int8 temp1, temp2;
signed int16 temp3;
float result;

onewire_reset();
onewire_write(0xCC);
onewire_write(0x44);
delay_ms(200);

onewire_reset();
onewire_write(0xCC);
onewire_write(0xBE);
temp1 = onewire_read();
temp2 = onewire_read();
temp3 = make16(temp2, temp1);

result = (float) temp3 / 16.0; //Calculation for DS18B20 with 0.1 deg C resolution

delay_ms(200);
return(result);
}


//void LCD_Init (); // ham khoi tao LCD
//void LCD_Char ( char X ); // Ham ghi 1kitu/1chuoi len LCD
//void LCD_Cmd (int X) ; // Ham ghi lenh len LCD
//void LCD_PulseEnable (); // Ham cho phep hoac khong

void LCD_Char (char X)
{
output_high(RS);
output_low(RW);
output_D(X);
output_high(E);
output_low(E);
delay_ms( 30 );
}

void LCD_Cmd (int X)
{
output_low(RS);
output_low(RW);
output_D(X);
output_high(E);
output_low(E);
delay_ms( 30 );
}

void LCD_Init ()
{
output_d(0x00);
delay_ms(100);
LCD_Cmd(0x02);
LCD_Cmd(0x38); // giao tiep 8 bit 2 dong, font 5x7
LCD_Cmd(0x0C); // bat hien thi, tat con tro
LCD_Cmd(0x06); // tang con tro
LCD_Cmd(0x01); // xoa man hinh
}


void main()
{
set_tris_E(1);

LCD_Init();
LCD_Cmd(0x01);
lcd_Cmd(0x80);
LCD_Char("DO AN TOT NGHIEP");
lcd_Cmd(0xC0);
LCD_Char(" VI XU LY");
delay_ms(1500);

LCD_Cmd(0x01);
lcd_Cmd(0x80);
LCD_Char("SVTH:VO VAN NHUT");
lcd_Cmd(0xC0);
LCD_Char("NGUYEN TIEN DAT");
delay_ms(1500);

if(button==0)
{
while(button==0)
{};
t++;
}

lcd_cmd(0x01);
while(1)
{
lcd_Cmd(0x80);
LCD_Char("NHIET DO:");
lcd_cmd(0x89);
printf(LCD_Char,"%3d",t);
lcd_char(223);
lcd_char("C");

LCD_Cmd(0xC0);
lcd_char("HCM CITY:");
nhietdo=ds18b20_read();
LCD_Cmd(0xC9);
Printf(LCD_Char,"%3.1f",nhietdo);
LCD_Char(223);
LCD_Char("C");

if(nhietdo > t)
{
output_high(Buzz);
output_b(0xff);
output_c(0xff);
}
else if(nhietdo<=t)
{
output_low(Buzz);
output_b(0x00);
output_c(0x00);
}
}
}
onghatbekacdvn vẫn chưa có mặt trong diễn đàn   Trả Lời Với Trích Dẫn
 

Ðiều Chỉnh
Xếp Bài

Quyền Sử Dụng Ở Diễn Ðàn
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is Mở
Smilies đang Mở
[IMG] đang Mở
HTML đang Tắt

Chuyển đến


Múi giờ GMT. Hiện tại là 11:10 PM.


Được sáng lập bởi Đoàn Hiệp
Powered by vBulletin®
Page copy protected against web site content infringement by Copyscape
Copyright © PIC Vietnam