[原创]
很多人都喜欢用LED来做调试,看看这是共阴还是共阳
还有这个电阻是是多大的呢?
- #include "msp430g2211.h"
- #define LED4 BIT1
- #define LED3 BIT2
- #define LED2 BIT3
- #define LED1 BIT4
- #define LED0 BIT5
- #define BUZZER BIT6
- void main( void ) {
- // Stop watchdog timer to prevent time out reset
- WDTCTL = WDTPW + WDTHOLD;
- // Set DCO to 1MHz factory calibration value
- BCSCTL1 = CALBC1_1MHZ;
- DCOCTL = CALDCO_1MHZ;
- //all LED pins and buzzer as output
- P1DIR |= (LED0 + LED1 + LED2 + LED3 + LED4 + BUZZER);
- P1OUT |= LED0;
- P1OUT &= ~LED0;
- P1OUT |= LED1;
- P1OUT &= ~LED1;
- P1OUT |= LED2;
- P1OUT &= ~LED2;
- P1OUT |= LED3;
- P1OUT &= ~LED3;
- P1OUT |= LED4;
- P1OUT &= ~LED4;
- while(1){} //do nothing forever...
还有源码,看起来应该还漏掉了一个"}"