Ðăng Nhập

View Full Version : cảm biến áp suất


boy_friend102vu
25-12-2010, 03:02 PM
các bác xem dùm em đoạn code đo cảm biến áp suất này. ccs cứ báo lỗi dòng" else" và "||"


#define <16f877a.h>
#include "16F877A.h"
#device *=16 adc=8
//#device PIC16F877A *=16
#use delay(clock=12000000)

#FUSES NOWDT, HS, NOPUT, NOPROTECT, NODEBUG, NOBROWNOUT, NOLVP, NOCPD, NOWRT
//#use rs232(baud=115200,parity=N,xmit=PIN_C6,rcv=PIN_C7, bits=9)
#include <LCD.C>

int8 read;
void main(void)
{
// set_tris_b(0);
set_tris_a(0xFF);
set_tris_d(0x00);




//Khoi tao ADC
setup_adc_ports(AN0);
setup_adc(ADC_CLOCK_INTERNAL);
delay_ms(50);



while(TRUE)
{
lcd_init();
read=read_adc();
read =read*0.436 + 10.6;
if (read>115) || (read<15)
{
printf(lcd_putc,"!!");
}
else
{
printf(lcd_putc,"\rNhiet do: %u",read);
}
delay_us(20);
}

}

pk178
25-12-2010, 07:01 PM
Lỗi cú pháp thôi bạn.

Bạn sửa đoạn
if (read>115) || (read<15)

Thành

if ((read>115) || (read<15))