/node-build-leds

A node api to control ws2801 leds

Primary LanguageJavaScript

node-build-leds

A node application to control a ws2801 led stripe connected to a Raspberry Pi over http. Interfacing the RGB LED strip to the Raspberry Pi is super simple, requiring just a few connections between the board, strip and a DC power jack. Adafruit has a very good example here.

Install and run

git clone https://github.com/Stmu/node-build-leds.git
npm install

node bin/www

Fill a specific range

Http-Request:

GET /led/from/:start/to/:to/fill/:color HTTP/1.1
HOST: raspi.address:3000

curl http://rapi.address:3000/led/from/:start/to/:to/fill/:color
  • :start first pixel with color
  • :to last pixel with color
  • :color hex color (without hash e.g. F7f7ab) value or color name like blue or yellow are possible

sample request

curl http://rapi.address:3000/led/from/0/to/31/fill/00FF00

Fill complete stripe with one post request

Http-Request:

POST /api/fill HTTP/1.1
HOST: raspi.address:3000
CONTENT-TYPE: application/json

{
    "duration": 5000,
    "r": 0,
    "g": 0,
    "b": 0
}

curl:

curl -X POST -H "Content-Type: application/json" -d "{ \"duration\": 1200000, \"r\": 0, \"g\": 127, \"b\": 127 }" http://rapi.address:3000/api/fill

Run a super duper cool demo

Http-Request:

POST /api/fill HTTP/1.1
HOST: raspi.address:3000
CONTENT-TYPE: application/json

{
    "start": true
}

curl:

curl -X POST -H "Content-Type: application/json" -d "{\"start\": true}" http://rapi.address:3000/api/demo

Stop the demo

Http-Request:

POST /api/fill HTTP/1.1
HOST: raspi.address:3000
CONTENT-TYPE: application/json

{
    "start": false
}

curl:

curl -X POST -H "Content-Type: application/json" -d "{ \"start\": false}" http://rapi.address:3000/api/demo

Fill a range of the stripe

fills a specific range of leds with given colors

Http-Request:

POST /api/range HTTP/1.1
HOST: raspi.address:3000
CONTENT-TYPE: application/json

{
    "from": 0,
    "to": 31,
    "rgb": "#FF00FF",
    "duration":5000
}

curl:

curl -X POST -H "Content-Type: application/json" -d "{ \"from\": 0, \"to\": 31, \"rgb\": \"#FF00FF\", \"duration\": 1200000 }" http://rapi.address:3000/api/range

Color a specific led of the stripe

Sets the given color name of a specific LED on the stripe.

NUMBER: index of the LED (e.g. 0 to 31 if your stripe has 32 LEDs) COLOR: the name of the color. Supported color names are found in app/controller/rgbcolor.js

curl sample call:

curl http://rapi.address:3000/led/<NUMBER>/fill/<COLOR>