Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <msp430.h>
- #pragma vector = PORT1_VECTOR
- void if_first_button_is_pressed(void){
- P2OUT |= 1<<5;
- __delay_cycles(3000000);
- P2OUT &= ~(1<<5);
- }
- void if_fourth_button_is_pressed(void){
- P2OUT |= 1<<1;
- __delay_cycles(3000000);
- P2OUT &= ~(1<<1);
- }
- int main(void){
- WDTCTL = WDTPW | WDTHOLD; // stop watchdog timer
- DCOCTL = 0;
- BCSCTL1 = CALBC1_1MHZ;
- DCOCTL = CALDCO_1MHZ;
- P1DIR &= ~1<<3; //button 1
- P2DIR |= 1<<5; //motor pin 1
- P1DIR &= ~(3); // pull down resistor button
- P1REN |= 3;
- P1OUT &= ~(3);
- P2DIR &= ~1; //button 2
- P2DIR |= 1<<1; //motor pin 2
- P2DIR &= ~1; // pull down resistor button
- P2REN |= 1;
- P2OUT &= ~1;
- while(1){
- if((P1IN & 1<<3) == 1){
- if_first_button_is_pressed();
- }else if((P1IN & 1<<3) == 0){
- P2OUT &= ~(1<<5);
- }if((P2IN & 1) == 1){
- if_fourth_button_is_pressed();
- }else if((P2IN & 1) == 0){
- P2OUT &= ~(1<<1);
- }
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement