Advertisement
Guest User

Untitled

a guest
Nov 16th, 2013
120
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 1.60 KB | None | 0 0
  1. #include <18F46K20.h>
  2. #use delay (clock=8000000)
  3. #fuses INTRC_IO,NOWDT,NOPROTECT, PUT, MCLR
  4.  
  5. //i=bottone + /j=bottone - /k=frequenza
  6. unsigned int 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.       if(input(BUTT1)==1) {
  35.       k=k+10;
  36.       output_high(LED7);
  37.       delay_ms(10);
  38.       output_low(LED7);
  39.       if(k==110) {
  40.          k=100;
  41.          output_high(LED7);
  42.          delay_ms(30);
  43.          output_low(LED7);
  44.          }
  45.       }
  46.       if(input(BUTT2)==1) {
  47.       k=k-10;
  48.       output_high(LED7);
  49.       delay_ms(10);
  50.       output_low(LED7);
  51.       if(k==0) {
  52.          k=10;
  53.          output_high(LED7);
  54.          delay_ms(30);
  55.          output_low(LED7);
  56.          }
  57.       }
  58.      
  59.       output_high(LED1);
  60.       delay_ms(k);
  61.       output_low(LED1);
  62.       output_high(LED2);
  63.       delay_ms(k);
  64.       output_low(LED2);
  65.       output_high(LED3);
  66.       delay_ms(k);
  67.       output_low(LED3);
  68.       output_high(LED4);
  69.       delay_ms(k);
  70.       output_low(LED4);
  71.       output_high(LED5);
  72.       delay_ms(k);
  73.       output_low(LED5);
  74.       output_high(LED6);
  75.       delay_ms(k);
  76.       output_low(LED6);
  77.          
  78.   }
  79. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement