Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <18F46K20.h>
- #use delay (clock=8000000)
- #fuses INTRC_IO,NOWDT,NOPROTECT, PUT, MCLR
- //i=bottone + /j=bottone - /k=frequenza
- unsigned int k;
- #define LED1 PIN_B5
- #define LED2 PIN_B4
- #define LED3 PIN_B3
- #define LED4 PIN_B2
- #define LED5 PIN_B1
- #define LED6 PIN_B0
- #define LED7 PIN_D7
- #define BUTT1 PIN_C3
- #define BUTT2 PIN_C2
- void main(){
- output_high(LED1);
- output_high(LED2);
- output_high(LED3);
- output_high(LED4);
- output_high(LED5);
- output_high(LED6);
- delay_ms(100);
- output_low(LED1);
- output_low(LED2);
- output_low(LED3);
- output_low(LED4);
- output_low(LED5);
- output_low(LED6);
- delay_ms(100);
- k=50;
- while (1) {
- if(input(BUTT1)==1) {
- k=k+10;
- output_high(LED7);
- delay_ms(10);
- output_low(LED7);
- if(k==110) {
- k=100;
- output_high(LED7);
- delay_ms(30);
- output_low(LED7);
- }
- }
- if(input(BUTT2)==1) {
- k=k-10;
- output_high(LED7);
- delay_ms(10);
- output_low(LED7);
- if(k==0) {
- k=10;
- output_high(LED7);
- delay_ms(30);
- output_low(LED7);
- }
- }
- output_high(LED1);
- delay_ms(k);
- output_low(LED1);
- output_high(LED2);
- delay_ms(k);
- output_low(LED2);
- output_high(LED3);
- delay_ms(k);
- output_low(LED3);
- output_high(LED4);
- delay_ms(k);
- output_low(LED4);
- output_high(LED5);
- delay_ms(k);
- output_low(LED5);
- output_high(LED6);
- delay_ms(k);
- output_low(LED6);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement