Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <18F46K20.h>
- #use delay(clock=4000000)
- #fuses INTRC_IO, NOWDT, BROWNOUT,NOPROTECT, PUT, MCLR, NOLVP
- //i=bottone + /j=bottone - /k=frequenza
- unsigned int i,j,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_D3
- #define BUTT2 PIN_D2
- void main(){
- setup_oscillator(OSC_4MHZ);
- 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) {
- i=input(BUTT1);
- j=input(BUTT2);
- if (i==1) {
- if (k<200) {
- k=k+10;
- output_high(LED7);
- delay_ms(100);
- output_low(LED7);
- }
- if (k=210) {
- k=200;
- output_high(LED7);
- delay_ms(300);
- output_low(LED7);
- }
- }
- if (j==1) {
- if (k>9) {
- k=k-10;
- output_high(LED7);
- delay_ms(100);
- output_low(LED7);
- }
- if (k=0) {
- k=10;
- output_high(LED7);
- delay_ms(300);
- output_low(LED7);
- }
- }
- delay_ms(50);
- }
- while (1) {
- output_high(LED1);
- delay_ms(k);
- output_low(LED1);
- delay_ms(k);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement