Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <xc.h>
- __PROG_CONFIG(1,0x3FE4);
- __PROG_CONFIG(2,0x1EFF);
- #define _XTAL_FREQ 16000000
- #define LED1 RB1
- #define LED2 RB2
- #define LED2 RB3
- void init_uC (void);
- void main(void)
- {
- int cnt = 0;
- init_uC();
- while (1)
- {
- cnt = 0;
- if(RB0==0)
- {
- cnt++;
- __delay_ms(800);
- if(RB0 == 0) cnt++;
- __delay_ms(1000);
- if(RB0 == 0) cnt++;
- if(cnt == 1)
- {
- RB1 = 1;
- __delay_ms(1000);
- RB1 = 0;
- }
- if(cnt == 2)
- {
- RB2 = 1;
- __delay_ms(1000);
- RB2 = 0;
- }
- if(cnt == 3)
- {
- RB3 = 1;
- __delay_ms(1000);
- RB3 = 0;
- }
- }
- }
- }
- void init_uC (void)
- {
- OSCCON = 0x7B;
- TRISB = 0b00000001;
- ANSELB = 0b00000000;
- PORTB = 0b00000000;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement