Other Parts Discussed in Thread: MSP430G2231
i'am begining with MCU, and i wrote the code by C language for MSP430g2231, i don't know how to define for a bit. for example, using bit_3 of port1 for input(a button), and bit_0 of port 1 for output(light Led). when i press the button the output=1(turn on/off the led). when i compile the code, there is an erro at the first line. i don't know how to define for (in/out)bit. please help me!
quyenanh1@gmail.com
thank you!
#include<io430gxxxx.h>
#include <msp430g2231.h>
#define buton P1IN_bit.P1IN_3
#define led P1OUT_bit.P1OUT_0
void main(void)
{
WDTCTL = WDTPW + WDTHOLD; // Stop watchdog timer
P1DIR |= 0x01; // Set P1.0 to output direction
led=1;
for(; ;){
if(buton){
led=~led;
}
}
}