#include "msp430g2231.h" #define LED1 BIT0 #define LED2 BIT6 void main(void) { WDTCTL = WDTPW + WDTHOLD; ADC10CTL0 = ADC10SHT_2 + ADC10ON + ADC10IE; ADC10CTL1 = INCH_1; ADC10AE0 |= 0x02; P1DIR |= LED1 + LED2; P1OUT &= ~(LED1 + LED2); for (;;) { ADC10CTL0 |= ENC + ADC10SC; while (ADC10CTL1 & ADC10BUSY); if (ADC10MEM < 0x1AA) { P1OUT &= ~LED2; P1OUT |= LED1; } else { P1OUT &= ~LED1; P1OUT |= LED2; } } }