Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #define DELAY 75
- #include <msp430.h>
- int main(void)
- {
- WDTCTL = WDTPW + WDTHOLD; // Stop WDT
- //LED CONFIGURATION
- P1DIR |= BIT1; //direction ->OUT
- P1DIR |= BIT2;
- P1DIR |= BIT3;
- P1DIR |= BIT4;
- P1DIR |= BIT5;
- P1OUT &= ~BIT1; //state ->OFF
- P1OUT &= ~BIT2;
- P1OUT &= ~BIT3;
- P1OUT &= ~BIT4;
- P1OUT &= ~BIT5;
- //BUTTON CONFIGURATION
- P2DIR &= ~BIT2; //direction ->IN
- P2REN |=BIT2; //pullup/pulldown enabled
- P2OUT &=~BIT2; // enable pulldown
- //STATE CONFIGURATION
- volatile char state = 0; //state of blinking
- volatile int i = 0; //cycle parameter
- for(;;){
- if(P2IN &=BIT2){ //if button pressed
- state ^= BIT0; //change blinking state
- }
- if(state & BIT0){
- for(i = 0; i<2; i++){
- P1OUT ^= BIT1; //LED inversion
- __delay_cycles(DELAY); //delay
- P1OUT ^= BIT2;
- __delay_cycles(DELAY);
- P1OUT ^= BIT3;
- __delay_cycles(DELAY);
- P1OUT ^= BIT4;
- __delay_cycles(DELAY);
- P1OUT ^= BIT5;
- __delay_cycles(DELAY);
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement