msp430 launchpad pin 접근하기

|


런치페드는 아두이노와는 다르게 포트번호게 P1.1 이런식으로 표기 되어 있습니다.







 P1.6 , P2.0 으로 표시된 핀들에 연결을 했습니다.


 p1.6 번으로 표기된 핀은 P1_6 으로...

 p2.0 번으로 표기된 핀은 P2_0 으로 접근하실수 있습니다.


예>

 pinMode(P1_6,OUTPUT);


테스트 동영상입니다.





예제소스>


/*

  DigitalReadSerial with on-board Pushbutton

  Reads a digital input on pin 5, prints the result to the serial monitor 

 

  Harware Required:

  * MSP-EXP430G2 LaunchPad

  

  This example code is in the public domain.

 */


int pushButton = P1_1;

int pushButton2 = P2_1;


int testLed = P1_6;

int testLed2 = P2_0;


// the setup routine runs once when you press reset:

void setup() {

  // initialize serial communication at 9600 bits per second:

  Serial.begin(9600); // msp430g2231 must use 4800

  // make the on-board pushbutton's pin an input pullup:

  pinMode(pushButton, INPUT_PULLUP);

  pinMode(pushButton2, INPUT_PULLUP);

  

  pinMode(testLed,OUTPUT);

  pinMode(testLed2,OUTPUT);

}


// the loop routine runs over and over again forever:

void loop() {

  // read the input pin:

  int buttonState = digitalRead(pushButton);

  // print out the state of the button:

  

  if(buttonState) {

    digitalWrite(testLed, HIGH); 

  }

  else {

    digitalWrite(testLed, LOW); 

  }


  if(digitalRead(pushButton2)) {

    digitalWrite(testLed2, HIGH); 

  }

  else {

    digitalWrite(testLed2, LOW); 

  }

  

  Serial.println(buttonState);

  delay(1);        // delay in between reads for stability

}






And