PIC Vietnam

Go Back   PIC Vietnam > Các Đề Tài > Các dự án mã nguồn mở

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

Các dự án mã nguồn mở Nếu bạn không mở mã nguồn, ít nhất là một phần nào đó trong dự án của bạn, xin đừng vào đây.

 
 
Ðiều Chỉnh Xếp Bài
Prev Previous Post   Next Post Next
Old 26-09-2011, 08:14 PM   #7
anhhungne69
Nhập môn đệ tử
 
Tham gia ngày: Oct 2010
Bài gửi: 4
:
xin sua giup code , minh dang lam do an nhiet dung 18b20 wet led 7 doan.thank

#include<16F877A.h>
#device *=16
#fuses HS,NOPROTECT,NOLVP, NOWDT, NOLVP, NOBROWNOUT,NOPUT
#USE delay(clock=2000000)
#define TOUCH_PIN pin_a0
#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 2byte du lieu to Scratchpad
touch_write_byte(0x33);// ghi 2 byte Trong
touch_write_byte(0x33);//
touch_write_byte(0x1f);// cau hinh cho thanh ghi nhiet do (do phan giai 9 bit)
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);
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 nho nhap
tam1=touch_read_byte();//doc 2 byte nhiet do
tam2=touch_read_byte();//doc 2 byte nhiet do
}
}
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,7))//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à 11:07 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