I am only using the baseline msp430g2231 on the launchpad, very cheap device!
http://www.ti.com/product/msp430g2231
http://www.ti.com/tool/msp-exp430g2
Code: Select all
/*
The1's Square Wave FREQ Gen
nigel@eyeit.org
Push Button UP/Down
1hz increment
0-30,000hz Range
3.3V
P1_3 UP Button
P1_4 DOWN Button
P1_6 FREQ OUT
*/
const int buttonP1_3 = P1_3; // Define UP Button PIN
int buttonUP = 0; // Set UP Button to 0
const int buttonP1_4 = P1_4; // Define DOWN Button PIN
int buttonDOWN = 0; // Set DOWN Button to 0
int TempFreq = 2000; // Set Bootup Freq
int FreqInc = 1; // Pushbutton Freq Increment
void setup() {
// initialize the Buttons as an input:
pinMode(buttonP1_3, INPUT_PULLUP);
pinMode(buttonP1_4, INPUT_PULLUP);
}
void loop()
{
// Refresh for Bootup or Reset
analogFrequency (TempFreq) ; // Refresh Output on Bootup or Reset
analogWrite(P1_6, 127); // Send PWM to Pin P1_6 50% duty cycle
// Button UP Code
buttonUP = digitalRead(buttonP1_3); // read the state of the UP Button:
if (buttonUP == LOW) // check if the pushbutton is pressed = LOW.
{
TempFreq = TempFreq + FreqInc; // Add FreqInc to Current Output
analogFrequency (TempFreq) ; // Send New Output
analogWrite(P1_6, 127); // Send PWM to Pin P1_6 50% duty cycle
}
// Button DOWN Code
buttonDOWN = digitalRead(buttonP1_4);// read the state of DOWN Button:
if (buttonDOWN == LOW) // check if the pushbutton is pressed = LOW.
{
TempFreq = TempFreq - FreqInc; // Subract FreqInc From Current Output
analogFrequency (TempFreq) ; // Send New Output
analogWrite(P1_6, 127); // Send PWM to Pin P1_6 50% duty cycle
}
}