lee_trieu
Gà con
Chào mọi người !! Em đang có một vướn mắc chỗ đọc ADC hiện lên LCD mong mọi người giúp đỡ ạ
Vấn đề em vướn phải là hiện số thực lên LCD(Em dùng thư viện LCD của Câu lạc bộ)
Nhìn mạch dưới thì như mọi người thấy đó 3.10V nhưng nó lại làm tròn thành 3.00V
Em thử ép kiểu sang số thực nhưng không được
.
Em viết code thế này:
em thử sửa chỗ:
Thành
Thì 3.18V nó hiện ra 3.1V
link project của em:
https://dl.dropboxusercontent.com/u/23155150/ADC And LCD.rar

Vấn đề em vướn phải là hiện số thực lên LCD(Em dùng thư viện LCD của Câu lạc bộ)

Nhìn mạch dưới thì như mọi người thấy đó 3.10V nhưng nó lại làm tròn thành 3.00V
Em thử ép kiểu sang số thực nhưng không được


Em viết code thế này:
PHP:
#include <msp430g2553.h>
#include "conf_lcd.c"
int dienthe;
int main(void)
{
WDTCTL = WDTPW + WDTHOLD; // Stop WDT
ADC10CTL0 = ADC10SHT_2 + ADC10ON + ADC10IE; // ADC10ON, interrupt enabled
ADC10CTL1 = INCH_1 + CONSEQ_2; // input A1
ADC10AE0 |= 0x02; // PA.1 ADC option select
P2DIR |= 0x01;
conf_lcd(0);
lcd_clear();
for (;;)
{
dienthe= ((ADC10MEM*5)/1023)*100;
// dienthe=float(dienthe);
ADC10CTL0 |= ENC + ADC10SC; // Sampling and conversion start
// __bis_SR_register( CPUOFF + GIE); // LPM0, ADC10_ISR will force exit
lcd_gotoxy(0,0);
lcd_puts("Dien Ap:");
lcd_gotoxy(0,1);
lcd_number(dienthe,2,0);
lcd_gotoxy(4,1);
lcd_putc('V');
}
}
Code:
dienthe= ((ADC10MEM*5)/1023)*100;
và
lcd_number(dienthe,2,0);
Code:
dienthe= ((ADC10MEM*5*10)/1023);
và
lcd_number(dienthe,1,0);

https://dl.dropboxusercontent.com/u/23155150/ADC And LCD.rar