Advertisement
Guest User

Untitled

a guest
Nov 16th, 2013
146
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 1.45 KB | None | 0 0
  1. #include <18F46K20.h>
  2. #use delay (clock=4000000)
  3. #FUSES NOWDT                    //No Watch Dog Timer
  4.  
  5. //i=bottone + /j=bottone - /k=frequenza
  6. unsigned int i,j,k;
  7. #define LED1 PIN_B5
  8. #define LED2 PIN_B4
  9. #define LED3 PIN_B3
  10. #define LED4 PIN_B2
  11. #define LED5 PIN_B1
  12. #define LED6 PIN_B0
  13. #define LED7 PIN_D7
  14. #define BUTT1 PIN_C3
  15. #define BUTT2 PIN_C2
  16.  
  17. void main(){
  18.   output_high(LED1);
  19.   output_high(LED2);
  20.   output_high(LED3);
  21.   output_high(LED4);
  22.   output_high(LED5);
  23.   output_high(LED6);
  24.   delay_ms(100);
  25.   output_low(LED1);
  26.   output_low(LED2);
  27.   output_low(LED3);
  28.   output_low(LED4);
  29.   output_low(LED5);
  30.   output_low(LED6);
  31.   delay_ms(100);
  32.   k=50;
  33.   while (1) {
  34.       i=input(BUTT1);
  35.       j=input(BUTT2);
  36.       if (i==1) {
  37.           if (k<=200) {
  38.           k=k+10;
  39.           output_high(LED7);
  40.           delay_ms(100);
  41.           output_low(LED7);
  42.           }
  43.           if (k==210) {
  44.           k=200;
  45.           output_high(LED7);
  46.           delay_ms(300);
  47.           output_low(LED7);
  48.           }
  49.       }
  50.       else
  51.       {
  52.       }
  53.       if (j==1) {
  54.           if (k>=9) {
  55.           k=k-10;
  56.           output_high(LED7);
  57.           delay_ms(100);
  58.           output_low(LED7);
  59.           }
  60.           if (k==0) {
  61.           k=10;
  62.           output_high(LED7);
  63.           delay_ms(300);
  64.           output_low(LED7);
  65.           }
  66.       }
  67.       output_high(LED1);
  68.       delay_ms(k);
  69.       output_low(LED1);
  70.       delay_ms(k);
  71.   }
  72. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement