Single motor control example for MSP430G2452 and SN754410NE

20151007_164400

This was the final example program from today’s class:

//
// Single motor example for MSP430G2452
// Written by Ted Burke - Last modified 7-10-2015
//

#include <msp430.h>
 
int main( void )
{
    WDTCTL = WDTPW + WDTHOLD; // Disable watchdog timer
     
    P1DIR = 0b00000001; // P1.0 is the LED output
    P2DIR = 0b00110000; // P2.4 and P2.5 are motor outputs
     
    // Main loop repeats forever
    while(1)
    {
        if ((P1IN & BIT3) > 0)
        {
            // LED on and motor forwards for 2 seconds
            P1OUT = 0b00000001;      // LED on
            P2OUT = 0b00100000;      // Motor forward
        }
        else
        {
            // LED off and motor backwards for 2 seconds
            P1OUT = 0b00000000;      // LED off
            P2OUT = 0b00010000;      // Motor backwards
        }
    }
     
    // The program never actually reaches this point
    return 0;
}
Advertisements
This entry was posted in Uncategorized. Bookmark the permalink.

One Response to Single motor control example for MSP430G2452 and SN754410NE

  1. Pingback: Catching up! | Robo Sumo 2016

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s