#include //P1.3 ENA //P1.4 IN1 //P1.5 IN2 //P1.6 ENB //P2.0 IN3 //P2.1 IN4 int main(void) { WDTCTL = WDTPW | WDTHOLD; // Stop watchdog timer DCOCTL = 0; // BCSCTL1 = CALBC1_1MHZ; DCOCTL = CALDCO_1MHZ; P1SEL = BIT1; // P1.1 = RXD P1SEL2 = BIT1; // P1.1 = RXD UCA0CTL1 |=UCSWRST; UCA0CTL1 |= UCSSEL_2; UCA0BR0 = 104; // 1MHz 9600 baudrate UCA0BR1 = 0; // 1MHz 9600 baud rate UCA0MCTL = UCBRS0; // UART Baud adjustment UCA0CTL1 &= ~UCSWRST; IE2 |= UCA0RXIE; // USCI_A0 RX interrupt enable __bis_SR_register(LPM0_bits + GIE); // General interrrupts and LPM0 mode are active } #pragma vector=USCIAB0RX_VECTOR __interrupt void USCI0RX_ISR(void) { unsigned char received; received = UCA0RXBUF; if(received=='C') { //C=CENTER P1OUT &= ~(BIT3 + BIT6); } else if(received=='R') { //R=RIGHT P1OUT |=(BIT3 + BIT4); P1OUT &= ~BIT5; } else if(received=='L') { //L=LEFT P1OUT |=BIT6; P2OUT |=BIT0; P2OUT &= ~BIT1; } else if(received=='F') { //F=FORWARD P1OUT |=(BIT3 + BIT6); P1OUT |=BIT4; P1OUT &= ~BIT5; P2OUT |=BIT0; P2OUT &= ~BIT1; } else if(received=='B') { //B=BACK P1OUT |=(BIT3 + BIT6); P1OUT |=BIT5; P1OUT &= ~BIT4; P2OUT |= BIT1; P2OUT &= ~BIT0; } else if(received=='N') { //N=NO MOTION P1OUT &= ~(BIT3 + BIT6); } }