Tool/software: Code Composer Studio
Hello guys,
I have a problem about my code. I am newbie programmer. I hope you can help me.
I can control LEDs with one potentiometer and i need to one more potentiometer. I want to use one of potentiometer to control green LED and use other potetiometer to control red LED. How can i do that?
#include "msp430g2553.h" #define LED0 BIT0 //red LED #define LED1 BIT6 //green LED unsigned int value=0; float input_voltage = 0; void main(void) { WDTCTL = WDTPW + WDTHOLD; // Disable Watchdog timer BCSCTL1 = CALBC1_16MHZ; // Set Clock Frequencies (16 MHz) DCOCTL = CALDCO_16MHZ; P1DIR |= LED0 + LED1; // P1SEL |= BIT5; //ADC Input pin P1.5 P1OUT &= ~(LED0 + LED1); ADC10CTL1 = INCH_5; // Channel 5 ADC10CTL0 = SREF_1 + ADC10SHT_3 + ADC10ON + ADC10IE + REFON + REF2_5V; ADC10AE0 |= BIT5; //P1.5 ADC option value=0; while(1) { __delay_cycles(2000); // Delay for ADC ADC10CTL0 |= ENC + ADC10SC; // Sampling and conversion start value = ADC10MEM; input_voltage = (float)value*2.5/1023; //Convert back to voltage if (input_voltage >1.5) { P1OUT &= ~LED1; P1OUT |= LED0; } else if (input_voltage <1.5) //input_voltage less than or equal to 1.5 V { P1OUT &= ~LED0; P1OUT |= LED1; __delay_cycles(10000); } } //end while } //end main