Rev 2596 Rev 2600
Line 1... Line 1...
1 #include ".\main.h" 1 #include ".\main.h"
2 //#include <LCD.C> 2 //#include <LCD.C>
3   3  
-   4 #define LED1 PIN_C6 //CHANGE PIN_XX TO YOUR LED PIN NUMBER, EX: PIN_A5
-   5 #define LED2 PIN_C5 //CHANGE PIN_XX TO YOUR LED PIN NUMBER, EX: PIN_A5
-   6 #define LED3 PIN_C4 //CHANGE PIN_XX TO YOUR LED PIN NUMBER, EX: PIN_A5
-   7 #define LED4 PIN_D3 //CHANGE PIN_XX TO YOUR LED PIN NUMBER, EX: PIN_A5
4   8  
-   9  
-   10 #int_EXT
-   11 void EXT_isr(void)
-   12 {
5 #define LED PIN_C6 //CHANGE PIN_XX TO YOUR LED PIN NUMBER, EX: PIN_A5 13 output_toggle(LED3);
-   14 }
6   15  
7 //#define LCD_TYPE 1 16 //#define LCD_TYPE 1
8 //#include <lcd.c> 17 //#include <lcd.c>
9 void main() 18 void main()
10 { 19 {
11 unsigned int setpoint; 20 unsigned int setpoint;
12 unsigned int napeti; 21 unsigned int napeti;
13 unsigned int plneni=0; 22 unsigned int16 plneni=0;
14   23  
15 /* lcd_init(); 24 /* lcd_init();
16   25  
17 lcd_putc("\fReady...\n"); 26 lcd_putc("\fReady...\n");
18   27  
Line 39... Line 48...
39   48  
40 set_pwm1_duty(0); 49 set_pwm1_duty(0);
41 set_pwm2_duty(0); 50 set_pwm2_duty(0);
42   51  
43   52  
-   53 output_high(LED1);
-   54 output_high(LED2);
-   55 output_high(LED3);
-   56 output_high(LED4);
-   57  
-   58 ext_int_edge( L_TO_H ); // Sets up EXT
-   59 enable_interrupts(INT_EXT);
-   60 enable_interrupts(GLOBAL);
-   61  
44 // lcd_init(); 62 // lcd_init();
45 63
46 setpoint = 60; 64 setpoint = 43;
47 65
48 while(true) 66 while(true)
49 { 67 {
50 set_adc_channel(1); 68 set_adc_channel(1);
51 delay_us(100); 69 delay_us(100);
52 napeti = read_adc(); 70 napeti = read_adc();
53   71  
54 if (napeti <= setpoint) 72 if (napeti <= setpoint)
55 { 73 {
56 if (plneni < 150) plneni++; 74 if (plneni < 300) plneni++;
-   75 output_low(LED2);
57 } 76 }
58 else 77 else
59 { 78 {
60 if (plneni > 0) plneni--; 79 if (plneni > 0) plneni--;
-   80 output_high(LED2);
61 } 81 }
62   82  
63 set_pwm1_duty(plneni); 83 set_pwm1_duty(plneni);
64 set_pwm2_duty(plneni); 84 set_pwm2_duty(1023-plneni);
65   85  
66 output_low(LED); -  
67 delay_ms(100); -  
68 output_high(LED); 86 output_toggle(LED1);
69 delay_ms(100); 87 delay_ms(10);
70 } 88 }
71   89  
72 } 90 }