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

RN42 블루트스 모듈 사용기

|






초기 설정은 다음과 같습니다.




블루투스를 잡으신 다음에 연결 테스트 하실려면 이와 같이 설정 해줍니다.


명령어 관련 문서는....

bluetooth_cr_UG-v1.0r.pdf





UART 에 연결하실때에는 반드시 3.3 V 에 연결하셔야하며 rx,tx 는 서로 교차되어 연결해주어야합니다.









And

node.js 로 raspberry sound system 만들기

|

1. 싸운드 환경 설치


다음과 같은 순서로 유틸리티들을 설치합니다.

  • The ALSA utilities:
    sudo apt-get install alsa-utils
  • MP3 tools:
    sudo apt-get install mpg321
  • WAV to MP3 conversion tool:
    sudo apt-get install lame


사운드 드라이버를 로드해줍니다.


  • sudo modprobe snd-bcm2835

제대로 설치 됐는지 확인하려면


  • sudo lsmod | grep 2835

출력디바이스를 지정합니다.

Select the output device for sound (0=auto, 1=analog, 2=HDMI):

  • sudo amixer cset numid=3 1

1번은 일반핀입니다. 2번은 hdhi단자로 출력하고싶을때 사용합니다.


혹시 소리가 나지 않앗다면 다음과 같이해서 볼륨을 조절합니다.


sudo amixer cset numid=1 n



n 이 볼륨값입니다. 퍼센테이지로 0~100%  사의 값을 넣어 주거나 0~400사이 값을 넣어줄수있습니다.


테스트는 다음과 같이 합니다. 커멘드 창에서 아래 명령어들을 입력 해봅니다.


  • aplay /usr/share/sounds/alsa/Front_Center.wav
  • speaker-test -t sine -f 440 -c 2 -s 1
  • mpg321 “Mannish Boy.mp3″

aplay 로는 wav 만 연주 가능합니다. mp3 는 mpg321 로 하셔야합니다.


기타 사항입니다.


It you get the following error message:

  • ALSA lib pcm.c:2217:(snd_pcm_open_noupdate) Unknown PCM cards.pcm.front

Edit the file /usr/share/alsa/alsa.conf:

  • sudo nano /usr/share/alsa/alsa.conf
  • change the line “pcm.front cards.pcm.front” to “pcm.front cards.pcm.default”

If you are using HDMI and cannot hear any audio at all change the following PIconfiguration setting:

  • edit the RasPI configuration file:
    sudo nano /boot/config.txt
  • uncomment the line:
    hdmi_drive=2
  • save the file and reboot the PI


출처 : 

http://cagewebdev.com/index.php/raspberry-pi-getting-audio-working/

http://www.raspberrypi-spy.co.uk/2013/06/raspberry-pi-command-line-audio/




2. 노드 플러그인 설치


alsa 개발 sdk 를 먼저 설치합니다.

sudo apt-get install libasound2-dev

npm install -g lame
npm install -g wav
npm install -g speaker


출처 :

http://nmecdesign.com/blog/audio-on-the-raspberry-pi-with-node-js/


3. 예제


var lame = require(theApp.module_path +'lame');

var wav = require(theApp.module_path +'wav');

var Speaker = require(theApp.module_path + 'speaker');


var wav_obj = {

                    file : fs.createReadStream('./effectsound/hit1.wav' ),

                    reader : new wav.Reader()

                };


                wav_obj.reader.on('format',function(format) {


                    //console.log(format);

                    wav_obj.speaker = new Speaker(format);


                    wav_obj.reader.pipe(wav_obj.speaker);




                });


                wav_obj.file.pipe(wav_obj.reader);


mp 의 경우는 reader stream을 lame 으로 하면된다.



And