Energia



Energia is a fork of Arduino’s Processing IDE for TI’s MSP430 microcontrollers.

Potentiometer


const int analogInPin = A0; // or P1_0 with Launchpad P1.0 Analog input pin that the potentiometer is attached to                             // or PB5  with StellarPad PB5 Analog input pin that the potentiometer is attached to

int sensorValue = 0;       // value read from the pot

void setup { // initialize serial communications at 9600 bps: Serial.begin(9600); // 4800 with msp430g2231 }

void loop { // read the analog in value: sensorValue = analogRead(analogInPin);

// print the results to the serial monitor: Serial.print("sensor = " ); Serial.print(sensorValue); Serial.println;

// wait 10 milliseconds before the next loop // for the analog-to-digital converter to settle // after the last reading: delay(10); }

3 Buttons Pad


/* Tree buttons pad */

// set pin numbers: const int button1Pin = P1_3;    // the number of the pushbutton pin const int button2Pin = P1_4;    // the number of the pushbutton pin const int button3Pin = P1_5;    // the number of the pushbutton pin const int ledPin = GREEN_LED;      // the number of the LED pin

// variables will change: boolean ledState = false;     // variable for reading the pushbutton status int buttonsStates = 0;        // variable for reading the pushbutton status

void setup { Serial.begin(9600);         // starts the serial monitor // initialize the LED pin as an output: pinMode(ledPin, OUTPUT); // initialize the pushbutton pin as an input: pinMode(button1Pin, INPUT_PULLUP); pinMode(button2Pin, INPUT_PULLUP); pinMode(button3Pin, INPUT_PULLUP); buttonsStates=readButtonsStates; Serial.println(buttonsStates); }

int readButtonsStates{ int _buttonsStates=0; if (digitalRead(button1Pin) == LOW) { _buttonsStates |= B1; } if (digitalRead(button2Pin) == LOW) { _buttonsStates |= B10; } if (digitalRead(button3Pin) == LOW) { _buttonsStates |= B100; } return _buttonsStates; }

void toogle{ if (ledState) { // turn LED off: digitalWrite(ledPin, LOW); } else { // turn LED on: digitalWrite(ledPin, HIGH); } ledState=!ledState; }

void loop{

int _buttonsStates=readButtonsStates; // send changes only if(buttonsStates != _buttonsStates) { buttonsStates = _buttonsStates; Serial.print(buttonsStates); toogle; // for debug } delay(50); }

Supported Boards

 * LaunchPad with msp430g2231,
 * LaunchPad with msp430g2452,
 * LaunchPad with msp430g2553,
 * FraunchPad with msp430fr5739
 * Stellaris Launchpad.

Pin mapping
https://github.com/energia/Energia/wiki/Hardware#wiki-LaunchPad_MSP430G2452

Links

 * https://github.com/energia/Energia/wiki
 * Forum http://forum.43oh.com/forum/28-energia/