PIC Vietnam

Go Back   PIC Vietnam > Microchip PIC > Analog - Bộ nhớ - Bảo mật - Cảm biến nhiệt độ

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

Analog - Bộ nhớ - Bảo mật - Cảm biến nhiệt độ Thảo luận việc sử dụng và thay thế các sản phẩm Analog, Memory, KEELOG và cảm biến nhiệt độ của Microchip cho các thiết kế

 
 
Ðiều Chỉnh Xếp Bài
Prev Previous Post   Next Post Next
Old 26-09-2011, 08:06 PM   #5
anhhungne69
Nhập môn đệ tử
 
Tham gia ngày: Oct 2010
Bài gửi: 4
:
xin sua giup , k biet loi o dau ma mach k chay dc

#include<16F877A.h>
#device *=16
#fuses HS,NOPROTECT,NOLVP,NOWDT,NOBROWNOUT,NOPUT
#USE delay(clock=2000000)
#define TOUCH_PIN pin_a3
#include<touch.c>
void hienthi(int8 a,int8 b,int8 c);
int8 const seg7[10]=
{0xc0,0xf9,0xa4,0xb0,0x99,0x92,0x82,0xf8,0x80,0x90 };
//chuong trinh chinh
//========================
void main(){
int8 tam1=0,tam2,ss,i;
int8 led1,led2,led3;
int16 nd;
//cai dat chuyen doi nhiet do 9bit
//========================
touch_present();
touch_write_byte(0xcc);// phat lenh skip ROM
touch_write_byte(0x4e);// phat lenh ghi 3byte du lieu to Scratchpad
touch_write_byte(0x0);// ghi 2 byte rong
touch_write_byte(0x0);//
touch_present();
touch_write_byte(0xCC);// skip ROM
touch_write_byte(0x48);//Sao chep Sratchpad vao Eeprom
//====vong lap chuong trinh chinh=====/
while(TRUE){
do{
if(touch_present())
{
touch_write_byte(0xCC);// phat lenh skip ROM
touch_write_byte(0x44);//xuat lenh chuyen doi nhiet do
for(i=0;i<7;++i)
{
hienthi(led1,led2,led3);
}
touch_present();
touch_write_byte(0xCC);
TOUCH_WRITE_BYTE(0xBE);//lenh doc bo o nho nhap
tam1=touch_read_byte();//doc 2 byte nhiet do
tam2=touch_read_byte();
}
}
while(tam1==ss);// so sanh gia tri nhiet do doc duoc voi gia tri truoc do
ss=tam1;
//==chuyen doi nhiet do sang so thap nhan====
nd=make16(tam2,tam1);
nd=nd>>4;//dich phat 4 bit
nd=nd&0x0ff;//lay 8 bit thap
if(bit_test(nd,8))//neu gia tri nhiet do am
{
led3=10;//led3 hien thi dau""-""
nd=~(--nd);//lay bu 2 gia tri nhiet do
nd=nd&0x0ff;// xoa byte cao
}
else// neu gia tri nhiet do duong
{
led3=nd/100;//led3 hien thi so hang tram
nd=nd%100;
}
led2=nd/10;//led2 hien thi so hang chuc
led1=nd%10;//led1 hien thi so hang don vi
}
}
//chuong trinh hien thi_quet led===
void hienthi(int8 a,int8 b,int8 c)
{
output_B(seg7[a]);
output_low(pin_d7);
delay_ms(1);
output_high(pin_d7);
output_B(seg7[b]);
output_low(pin_d6);
delay_ms(1);
output_high(pin_d6);
output_B(seg7[c]);
output_low(pin_d5);
delay_ms(1);
output_high(pin_d5);
}
anhhungne69 vẫn chưa có mặt trong diễn đàn   Trả Lời Với Trích Dẫn
 


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à 06:10 AM.


Đượ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