Hi all,
I am new to programming and want my MSP430 to read a voltage and light the LED at P1.0 if the voltage is less than a defined reference light P4.0 if it is equal to or over this reference. So far, I think I have set up my ADC input pin as A9 and my LEDs as P1.0 and P4.0. Any suggestions on what my next steps would be? Any sample code or explanation would be greatly appreciated .
Many thanks
#include <msp430.h>
#include <driverlib.h>
unsigned int voltage;
void configureADC()
{
//ADC setup
SYSCFG2 |= ADCPCTL9;
ADCCTL0 |= ADCON; // TURN ON ADC
ADCCTL1 |= ADCSHP;
ADCCTL1 |= ADCSSEL_2; // choose SMCLK
ADCCTL2 |= ADCRES_2; // clock res
ADCMCTL0 |= ADCSREF_7;
ADCMCTL0 |= ADCINCH_9; // A9 as input
ADCIFG &= ~0x01; //Clear interrupt flag
}
void init_LED() {
//configure ports
P1DIR |= BIT0; //configure LED1
P4DIR |= BIT0; //and LED2
}
int main(void)
{
WDTCTL = WDTPW | WDTHOLD; // stop watchdog timer
configureADC(); //initialising ADC
init_LED(); //initialising LED
PMM_unlockLPM5();
return 0;
}