PIC Vietnam

Go Back   PIC Vietnam > Microchip PIC > PIC - Thiết kế và Ứng dụng

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

PIC - Thiết kế và Ứng dụng Ý tưởng cho các sản phẩm sử dụng PIC/dsPIC và các sản phẩm của Microchip

Trả lời
 
Ðiều Chỉnh Xếp Bài
Old 27-03-2011, 11:46 PM   #1
stupid11
Đệ tử 6 túi
 
stupid11's Avatar
 
Tham gia ngày: Dec 2009
Nơi Cư Ngụ: TP.Hồ Chí Minh
Bài gửi: 133
:
Send a message via Yahoo to stupid11
Hiển thị chữ "HELLO WORLD"

#include <16f877a.h>
#fuses nowdt,noprotect,nolvp,put,hs
#use delaY(clock=4000000)

#byte portb=0x6
#byte porte=0x9

#bit e=0x9.0
#bit rs=0x9.1
#bit rw=0x9.2

int i;
char mang[]="HELLO WORLD";

void lenh()
{
rs=0;rw=0;e=1;e=0;
delay_ms(5);
}
void xuat()
{
e=1;rs=0;rw=0;e=0;
delay_ms(5);
}

void khoitao()
{
portb=0x1;lenh(); //xoa LCD
portb=0x38;lenh(); //hien thi 2 dong
portb=0x0e;lenh(); //bat hien thi
portb=0x02;lenh(); //dua con tro ve dau dong//
}

void main()
{
set_tris_b(0);
set_tris_e(0);
khoitao();
for(i=0;i<15;i++)
{
portb=mang[i];
xuat();
delay_ms(5);
}
while(1)
{}
}

thay đổi nội dung bởi: stupid11, 27-03-2011 lúc 11:59 PM.
stupid11 vẫn chưa có mặt trong diễn đàn   Trả Lời Với Trích Dẫn
Old 28-03-2011, 12:04 AM   #2
stupid11
Đệ tử 6 túi
 
stupid11's Avatar
 
Tham gia ngày: Dec 2009
Nơi Cư Ngụ: TP.Hồ Chí Minh
Bài gửi: 133
:
Send a message via Yahoo to stupid11
Smile

//Đo nhiệt đô hiển thị lên LCD và cảnh báo ở ngưỡng 50 oC//
//Phần cứng như sau:
porte:chân điều khiển
portb:xuất data
RA0:ngõ vào analog(từ LM35)
RA1:xuất cảnh báo

#include <16f877a.h>
#fuses nowdt,noprotect,nolvp,put,hs
#use delay(clock=4000000)

#byte portb=0x6
#byte porte=0x9

#bit e=0x9.0
#bit rs=0x9.1
#bit rw=0x9.2

int i,x;
char mang[]="nhiet do :";

void lenh()
{
rs=0;rw=0;e=1;e=0;
delay_ms(5);
}
void xuat()
{
e=1;rs=0;rw=0;e=0;
delay_ms(5);
}

void khoitao()
{
portb=0x1;lenh(); //xoa LCD
portb=0x38;lenh(); //hien thi 2 dong
portb=0x0e;lenh(); //bat hien thi
portb=0x02;lenh(); //dua con tro ve dau dong//
}

void doc_ADC()
{
setup_ADC(ADC_clock_internal);
stup_ports(AN0);
set_channel(0);
delay_ms(1);
}

void main()
{
set_tris_a(0b01);
set_tris_b(0);
set_tris_e(0);
khoitao();
for(i=0;i<12;i++)
{
portb=mang[i];
xuat();
delay_ms(5);
}
while(1)
{
doc_ADC();
X=read_ADC();
X=X*2.049 //ADC 10bit & LM35//
portb=0x89;lenh();//dua con tro LCD toi vi trí sau chu nhiet do:
//ban nen xem lai lenh nay..ko biet co dung vi tri ko nua~.

portb=x;xuat();
//canh bao//
if(x>50)
{
RA1=1 //
}
else
{
RA1=0;//
}
}}


Trong LCD có ký hiệu "oC" bạn chỉ việc

portb=0b00101110;xuat(); //bạn tham khảo thêm bảng mã LCD//

Chúc bạn thành công.
stupid11 vẫn chưa có mặt trong diễn đàn   Trả Lời Với Trích Dẫn
Old 05-07-2011, 10:39 AM   #3
pdkxlily
Đệ tử 2 túi
 
Tham gia ngày: Mar 2011
Bài gửi: 27
:
Trích:
Nguyên văn bởi stupid11 View Post

Trong LCD có ký hiệu "oC" bạn chỉ việc

portb=0b00101110;xuat(); //bạn tham khảo thêm bảng mã LCD//

Chúc bạn thành công.
Trích:
#include <16F877A.h>
#include <def_877a.h>
#device *=16 adc=8
#FUSES NOWDT, HS, NOPUT, NOPROTECT, NODEBUG, NOBROWNOUT, NOLVP, NOCPD, NOWRT
#use delay(clock=20000000)
#include <lcd_lib_4bit.c>


void convert_bcd(int8 x);
int8 t1,t2;
void main()
{



trisa = 0xFF;
trisb = 0x01;
trisd = 0x00;

LCD_init();
Printf(LCD_putchar,"Kenh 0,1:");
// Khoi tao cho ngat ngoai
enable_interrupts (INT_EXT);
ext_int_edge(H_TO_L);
enable_interrupts (GLOBAL);
// Khoi tao che do cho bo ADC
setup_adc_ports(AN0_AN1_AN3);
setup_adc(ADC_CLOCK_INTERNAL);
delay_us(10);
setup_adc_ports(AN0);



while(true)
{
set_ADC_channel(0);
t1 =(float)read_adc();
t1=t1/0.5102;
// convert_bcd((int8) t1);
LCD_putcmd(0xC0);
printf(LCD_putchar,"T0=%u",t1);
printf(LCD_putchar,"C");

set_ADC_channel(1);
t2=(float)read_adc();
t2=t2/0.5102;
LCD_putcmd(0xC7);
printf(LCD_putchar,"T1=%u",t2);
printf(LCD_putchar,"C");


}
}
mình làm lcd_4bit thì khúc xuất ra chữ độC ký tự đặc biệt thì mình làm sao bạn .thêm giúp mình với
pdkxlily vẫn chưa có mặt trong diễn đàn   Trả Lời Với Trích Dẫn
Trả lờ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à 02:56 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