Thursday, January 14, 2016

Toggle CHIPs LED though REST via node.js

Thought I'd make a quick test running node.js on the chip and what better way than to blink the on-board LED which is accessible on the i2c-bus :)
Clone https://github.com/larsenglund/chipled and cd into the repository folder, then make some binaries to toggle the LED:s (from http://wiki.geeky-boy.com/w/index.php?title=CHIP_Proj1)
sudo apt-get update  # Repair things that that seem to be a little sick.
sudo apt-get upgrade
sudo apt-get install -f locales
sudo locale-gen en_US en_US.UTF-8
sudo dpkg-reconfigure locales    # Select "en_US" locales.
sudo apt-get install gcc make  # Get the C compiler

sudo gcc -o on on.c  # Compile
sudo gcc -o off off.c
sudo chmod +s on  # Allow executables to run with root privilage
sudo chmod +s off
Install node.js, npm and dependecies for the project
sudo apt-get install nodejs
sudo apt-get install npm
npm install
And start the server
nodejs chipled.js
You should now be able to toggle the white on-board LED using the following URLs:
Time to build something a bit more interesting with this CHIP :)

Read more about CHIP at the Next Thing Co (NTC) website:http://getchip.com/pages/chip

No comments: