Rev Author Line No. Line
2596 kaklik 1 #include ".\main.h"
2 //#include <LCD.C>
3  
4  
5 #define LED PIN_C6 //CHANGE PIN_XX TO YOUR LED PIN NUMBER, EX: PIN_A5
6  
7 //#define LCD_TYPE 1
8 //#include <lcd.c>
9 void main()
10 {
11 unsigned int setpoint;
12 unsigned int napeti;
13 unsigned int plneni=0;
14  
15 /* lcd_init();
16  
17 lcd_putc("\fReady...\n");
18  
19 while (TRUE) {
20 k=kbd_getc();
21 if(k!=0)
22 if(k=='*')
23 lcd_putc('\f');
24 else
25 lcd_putc(k);
26 }
27 */
28  
29 setup_adc_ports(sAN0|VSS_VDD);
30 setup_adc(ADC_CLOCK_DIV_32);
31 setup_spi(SPI_SS_DISABLED);
32 setup_timer_0(RTCC_EXT_L_TO_H|RTCC_DIV_1);
33 setup_timer_1(T1_DISABLED);
34 setup_timer_2(T2_DIV_BY_1,255,1);
35 setup_ccp1(CCP_PWM);
36 setup_ccp2(CCP_PWM);
37 setup_comparator(NC_NC_NC_NC);// This device COMP currently not supported by the PICWizard
38 setup_oscillator(OSC_8MHZ);
39  
40 set_pwm1_duty(0);
41 set_pwm2_duty(0);
42  
43  
44 // lcd_init();
45  
46 setpoint = 60;
47  
48 while(true)
49 {
50 set_adc_channel(1);
51 delay_us(100);
52 napeti = read_adc();
53  
54 if (napeti <= setpoint)
55 {
56 if (plneni < 150) plneni++;
57 }
58 else
59 {
60 if (plneni > 0) plneni--;
61 }
62  
63 set_pwm1_duty(plneni);
64 set_pwm2_duty(plneni);
65  
66 output_low(LED);
67 delay_ms(100);
68 output_high(LED);
69 delay_ms(100);
70 }
71  
72 }