Vu meter ccs compiler pic programlama
#include<16f883.h>
#device adc=8
#use delay(int=4000000)
#include<LCD.C>
double map(float deger, float inputMin,
float inputMax, float outputMin,
float outputMax){
return ((((deger-inputMin)*
(outputMax-outputMin))/
(inputMax-inputMin))+outputMin);
}
void main(){
setup_adc_ports(sAN0|sAN1|VSS_VDD);
setup_adc(ADC_CLOCK_DIV_2);
lcd_init();
int8 output1, output2, i, j, okuAdc1, okuAdc2;
while(true){
set_adc_channel(0);
delay_us(10);
okuAdc1 = read_adc();
output1 = map(okuADC1, 0, 255, 0, 16);
set_adc_channel(1);
delay_us(10);
okuAdc2 = read_adc();
output2 = map(okuADC2, 0, 255, 0, 16);
lcd_init();
for(i=1;i<output1+1;i++){
lcd_gotoxy(i,1);
lcd_putc(0xFF);
}
for(j=1;j<output2+1;j++){
lcd_gotoxy(j,2);
lcd_putc(0xFF);
}
}
}
Hiç yorum yok:
Yorum Gönder
Her yorum bilgidir. Araştırmaya devam...