LTlib LaurTec Library
4.0.3
Open Source C Library for Microchip Microcontrollers based on XC8 Compiler
Main Page
Data Structures
Files
File List
Globals
All
Data Structures
Files
Functions
Variables
Typedefs
Enumerations
Enumerator
Macros
main.c
Go to the documentation of this file.
1
2
#include <xc.h>
3
4
#include <
LTlib.h
>
5
6
#include <
LTlib_delay.h
>
7
#include <
LTlib_delay.c
>
8
9
#include <
module_IO.h
>
10
#include <
module_IO.c
>
11
12
#include <
module_ADC.h
>
13
#include <
module_ADC.c
>
14
15
#include <
LCD_44780.h
>
16
#include <
LCD_44780.c
>
17
18
// Tested on Freedom II evaluation board
19
20
//Temperature channel
21
#define TEMPERATURE_CH ADC_CH2
22
23
//Light channel
24
#define LIGHT_CH ADC_CH0
25
26
int
main
(
void
){
27
28
unsigned
int
light_value = 0;
29
unsigned
int
temperature_value = 0;
30
31
IO_set_all_ports_as_inputs
();
32
33
LCD_initialize
(20);
34
35
ADC_open
(
LIGHT_CH
+
TEMPERATURE_CH
);
36
37
while
(1){
38
39
LCD_home
();
40
41
ADC_select_channel
(
TEMPERATURE_CH
);
42
ADC_start_conversion
();
43
while
(
ADC_is_converting
());
44
temperature_value =
ADC_read_value
()/2;
45
46
ADC_select_channel
(
LIGHT_CH
);
47
ADC_start_conversion
();
48
while
(
ADC_is_converting
());
49
light_value =
ADC_read_value
();
50
51
LCD_write_message
(
"Temp : "
);
52
LCD_write_integer
(temperature_value, 4,
LCD_ZERO_CLEANING_ON
);
53
LCD_write_char
(223);
54
LCD_write_char
(
'C'
);
55
56
LCD_goto_line
(2);
57
58
LCD_write_message
(
"Light : "
);
59
LCD_write_integer
(light_value, 4,
LCD_ZERO_CLEANING_ON
);
60
}
61
}
LTlib_v_4.0.3
ex
PIC18
_module_ADC
02 - Light_and_Temperature_read.X
main.c
Generated on Wed Aug 3 2016 19:57:31 for LTlib LaurTec Library by
1.8.3.1