0% found this document useful (0 votes)
641 views1 page

Breathing Led Using Msp430

This document summarizes code to create a breathing LED effect using an MSP430 launchpad and PWM signals. The code initializes a counter variable and direction variable, sets up a timer interrupt on P1.6 to increment or decrement the counter by 5 each time to increase and decrease the LED brightness in a cycle, and puts the MCU to sleep with interrupts enabled.

Uploaded by

Sudhanshu Seth
Copyright
© Attribution Non-Commercial (BY-NC)
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
641 views1 page

Breathing Led Using Msp430

This document summarizes code to create a breathing LED effect using an MSP430 launchpad and PWM signals. The code initializes a counter variable and direction variable, sets up a timer interrupt on P1.6 to increment or decrement the counter by 5 each time to increase and decrease the LED brightness in a cycle, and puts the MCU to sleep with interrupts enabled.

Uploaded by

Sudhanshu Seth
Copyright
© Attribution Non-Commercial (BY-NC)
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
You are on page 1/ 1

//breathing led effect with msp430 launchpad. Used pwm signal #include <msp430g2231.

h> int Counter = 1000;//defining variable int up = 1;//defining variable void main(void) { WDTCTL = WDTPW + WDTHOLD; P1DIR |= BIT6; P1SEL |= BIT6; ital I/O. CCTL0 = CCIE; CCR0 = 1000; CCTL1 = OUTMOD_3; CCR1 = 1000; TACTL = TASSEL_2 + MC_1 + ID_3; _bis_SR_register(LPM0_bits + GIE); } #pragma vector = TIMERA0_VECTOR __interrupt void Timer_A (void) { if( up ) Counter = Counter - 5; //setitng of code so that counter decr eases and increases so that our led's brightness increases and decreases else Counter = Counter + 5; CCR1 = Counter; if( Counter <= 0 ) up = 0; if( Counter >= 1000 ) up = 1; } //initializing watchdog timer //setting bit 6 i.e. p1.6 as o/p //selecting P1.6 pin to be used as dig //CCR0 interrupt enabled //setting the count //Set/Reset //setting the count for timer1 //enter LPM0 with interrrupt enable

You might also like