Line 1... |
Line 1... |
1 |
#include "C:\RS\Lux10brf\main.h" |
1 |
#include "C:\RS\Lux10brf\main.h" |
2 |
|
2 |
|
3 |
#define LCD_RS PIN_B1 // rizeni registru LCD displeje |
3 |
#define LCD_RS PIN_B0 // rizeni registru LCD displeje |
4 |
#define LCD_E PIN_B0 // enable LCD displeje |
4 |
#define LCD_E PIN_B1 // enable LCD displeje |
5 |
#define LCD_DATA_LSB PIN_C4 // pripojeni LSB bitu datoveho portu LCD displeje (celkem 4 bity vzestupne za sebou) |
5 |
#define LCD_DATA_LSB PIN_C4 // pripojeni LSB bitu datoveho portu LCD displeje (celkem 4 bity vzestupne za sebou) |
6 |
#define LUX1 PIN_B2 |
6 |
#define LUX1 PIN_B2 |
7 |
#define LUX2 PIN_B3 |
7 |
#define LUX2 PIN_B3 |
8 |
#define LUX3 PIN_B4 |
8 |
#define LUX3 PIN_B4 |
9 |
#define LUX4 PIN_B5 |
9 |
#define LUX4 PIN_B5 |
Line 29... |
Line 29... |
29 |
|
29 |
|
30 |
set_adc_channel (IN); |
30 |
set_adc_channel (IN); |
31 |
delay_us(20); |
31 |
delay_us(20); |
32 |
lcd_init(); |
32 |
lcd_init(); |
33 |
|
33 |
|
- |
|
34 |
|
34 |
while(TRUE) |
35 |
while(TRUE) |
35 |
{ |
36 |
{ |
36 |
I=read_adc(); |
37 |
I=read_adc(); //pøeètení hodnoty z A/D pøevodníku |
37 |
delay_us(600); |
38 |
delay_us(600); |
- |
|
39 |
E=0.009775*I; //výpoèet osvìtlení k=10.0/1023 |
38 |
E=0.019531*I; |
40 |
|
39 |
if(!input(LUX1)) |
41 |
if(!input(LUX1)) |
40 |
{ |
42 |
{ |
41 |
printf(lcd_putc," E=%4.2f lx \n",E); |
43 |
printf(lcd_putc," E=%3.1f lx \n",10*E); |
42 |
printf(lcd_putc," rozsah 1\n\r"); |
44 |
printf(lcd_putc," rozsah k1 \n\r"); |
43 |
delay_ms(300); |
- |
|
44 |
} |
45 |
} |
45 |
if(!input(LUX2)) |
46 |
if(!input(LUX2)) |
46 |
{ |
47 |
{ |
47 |
printf(lcd_putc," E=%3.1f lx \n",10*E); |
48 |
printf(lcd_putc," E=%3.0f lx \n",100*E); |
48 |
printf(lcd_putc," rozsah 2\n\r"); |
49 |
printf(lcd_putc," rozsah 1k \n\r"); |
49 |
delay_ms(300); |
- |
|
50 |
} |
50 |
} |
51 |
if(!input(LUX3)) |
51 |
if(!input(LUX3)) |
52 |
{ |
52 |
{ |
53 |
printf(lcd_putc," E=%4.0f lx \n",100*E); |
53 |
printf(lcd_putc," E=%3.2f klx \n",E); |
54 |
printf(lcd_putc," rozsah 3\n\r"); |
54 |
printf(lcd_putc," rozsah 10k \n\r"); |
55 |
delay_ms(300); |
- |
|
56 |
} |
55 |
} |
57 |
if(!input(LUX4)) |
56 |
if(!input(LUX4)) |
58 |
{ |
57 |
{ |
59 |
printf(lcd_putc," E=%3.1f klx \n",E); |
58 |
printf(lcd_putc," E=%3.1f klx \n",10*E); |
60 |
printf(lcd_putc," rozsah 4\n\r"); |
59 |
printf(lcd_putc," rozsah 100k \n\r"); |
61 |
delay_ms(300); |
- |
|
62 |
} |
60 |
} |
- |
|
61 |
delay_ms(300); |
63 |
while(!input(HOLD)); |
62 |
while(!input(HOLD)); //podrení hodnoty |
64 |
} |
63 |
} |
65 |
} |
64 |
} |