LTlib LaurTec Library  4.0.3
Open Source C Library for Microchip Microcontrollers based on XC8 Compiler
 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 
32 
33  LCD_initialize(20);
34 
36 
37  while(1){
38 
39  LCD_home();
40 
43  while(ADC_is_converting());
44  temperature_value = ADC_read_value()/2;
45 
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 }