#include "C:\RS\Lux10brf\main.h"
#define LCD_RS PIN_B1 // rizeni registru LCD displeje
#define LCD_E PIN_B0 // enable LCD displeje
#define LCD_DATA_LSB PIN_C4 // pripojeni LSB bitu datoveho portu LCD displeje (celkem 4 bity vzestupne za sebou)
#define LUX1 PIN_B2
#define LUX2 PIN_B3
#define LUX3 PIN_B4
#define LUX4 PIN_B5
#define HOLD PIN_B6
#define IN 0
#include "lcd.c"
void main()
{
unsigned int16 I;
float E;
port_b_pullups(TRUE);
setup_adc_ports(AN0_VREF_VREF);
setup_adc(ADC_CLOCK_DIV_32);
setup_psp(PSP_DISABLED);
setup_spi(SPI_SS_DISABLED);
setup_timer_0(RTCC_INTERNAL|RTCC_DIV_1);
setup_timer_1(T1_DISABLED);
setup_timer_2(T2_DISABLED,0,1);
setup_comparator(NC_NC_NC_NC);
setup_vref(FALSE);
set_adc_channel (IN);
delay_us(20);
lcd_init();
while(TRUE)
{
I=read_adc();
delay_us(600);
E=0.019531*I;
if(!input(LUX1))
{
printf(lcd_putc," E=%4.2f lx \n",E);
printf(lcd_putc," rozsah 1\n\r");
delay_ms(300);
}
if(!input(LUX2))
{
printf(lcd_putc," E=%3.1f lx \n",10*E);
printf(lcd_putc," rozsah 2\n\r");
delay_ms(300);
}
if(!input(LUX3))
{
printf(lcd_putc," E=%4.0f lx \n",100*E);
printf(lcd_putc," rozsah 3\n\r");
delay_ms(300);
}
if(!input(LUX4))
{
printf(lcd_putc," E=%3.1f klx \n",E);
printf(lcd_putc," rozsah 4\n\r");
delay_ms(300);
}
while(!input(HOLD));
}
}