RaspberryPiでNode-REDが使えるようになった

#はじめに
RaspberryPiでNode-REDが標準パッケージになったと聞いたので早速入れてみました。
[参考サイト](http://nodered.org/docs/hardware/raspberrypi.html)

#準備
RaspberryPiを用意します。
今回はRaspberryPi2を使いました。
基本のセットアップは[こんなかんじ](http://qiita.com/powmana02/items/bc8ba3036f348747473d)


#インストール
Raspbian-Jessieの[フル版](https://www.raspberrypi.org/downloads/raspbian/)をインストールするとNode-REDがついてきます。
別のバージョン/Lite版の場合は、apt-getで入手します。

```sudo apt-get install nodered
```


#起動
`node-red-start`コマンドを実行すると、ブラウザからアクセスできるURLがコンソールに表示されます。


```
pi@raspberrypi:~$ node-red-start


Once Node-RED has started, point a browser at http://192.168.128.59:1880

To stop Node-RED use the command   node-red-stop

Starting nodered (via systemctl): nodered.service.

Node-RED service start: Sat 12 Dec 11:17:21 UTC 2015


Welcome to Node-RED
===================

12 Dec 11:17:26 - [info] Node-RED version: v0.12.1
12 Dec 11:17:26 - [info] Node.js  version: v0.10.29
12 Dec 11:17:26 - [info] Loading palette nodes
12 Dec 11:17:36 - [info] Settings file  : /home/pi/.node-red/settings.js
12 Dec 11:17:36 - [info] User directory : /home/pi/.node-red
12 Dec 11:17:36 - [info] Flows file : /home/pi/.node-red/flows_raspberrypi.json
12 Dec 11:17:36 - [info] Server now running at http://127.0.0.1:1880/
12 Dec 11:17:36 - [info] Creating new flow file
12 Dec 11:17:36 - [info] Starting flows
12 Dec 11:17:36 - [info] Started flows
http://192.168.128.59:1880
pi@raspberrypi:~$
```

RaspberryPi用のノードとかもあります。

![rpi_nodered01.png](https://qiita-image-store.s3.amazonaws.com/0/71361/cceb7de5-6394-84d6-1179-11bcf76b60a0.png)


#GPIO制御してみる
Lチカ
tweetに"raspberrypi"が含まれるor含まれない　を条件にしてLチカします。
![rpi_nodered02.png](https://qiita-image-store.s3.amazonaws.com/0/71361/3c9339d1-cb7f-d656-f8b6-8022c5ea5d21.png)
![rpi_nodered03.png](https://qiita-image-store.s3.amazonaws.com/0/71361/930a7b3d-9f15-3b7a-521d-62a3abf7ecd5.png)

<b><font color="pink">ピンク</font>のLEDがかわいいでしょ！！</b>
![lchika_nodered.jpg](https://qiita-image-store.s3.amazonaws.com/0/71361/0954114a-be35-40ca-b856-625a888575d0.jpeg)

#NodeREDのフローはこちら
```
[{"id":"62948a9a.228c6c","type":"rpi-gpio out","z":"5015cd83.a920ac","name":"GPIO26","pin":"37","set":true,"level":"0","out":"out","x":605,"y":241,"wires":[]},{"id":"71ecf63e.cbe82","type":"twitter in","z":"5015cd83.a920ac","twitter":"","tags":"#GPIO","user":"false","name":"GPIO talk","topic":"tweets","x":99,"y":237,"wires":[["bec1e157.58b2e8"]]},{"id":"bf83350c.f74878","type":"debug","z":"5015cd83.a920ac","name":"","active":true,"console":"false","complete":"payload","x":603,"y":143,"wires":[]},{"id":"bec1e157.58b2e8","type":"switch","z":"5015cd83.a920ac","name":"text match","property":"payload","rules":[{"t":"cont","v":"raspberrypi"},{"t":"else"}],"checkall":"true","outputs":2,"x":257,"y":239,"wires":[["651ad091.1f3238"],["1445b39.2a5edcc"]]},{"id":"651ad091.1f3238","type":"function","z":"5015cd83.a920ac","name":"return 1","func":"return {payload:1};\n","outputs":1,"noerr":0,"x":426,"y":210,"wires":[["62948a9a.228c6c","bf83350c.f74878"]]},{"id":"1445b39.2a5edcc","type":"function","z":"5015cd83.a920ac","name":"return 0","func":"return {payload:0};\n","outputs":1,"noerr":0,"x":432,"y":267,"wires":[["62948a9a.228c6c","2aa75411.36e92c"]]},{"id":"2aa75411.36e92c","type":"debug","z":"5015cd83.a920ac","name":"","active":true,"console":"false","complete":"false","x":601,"y":362,"wires":[]}]
```