This demo is to show how to control the Edison's GPIOs using a web interface with a NodeJS server running on the Edison, with the Edison Ethernet board.
-
Clone the repo onto the Edison (or your dev environment):
git clone https://github.com/LGSInnovations/edison-gpio-example.git
-
cd
into theedison-gpio-example
directory and install dependencies:cd edison-gpio-example/ npm install && bower install
Note: In order to do this, you must have
node
andnpm
installed. Then to installbower
runnpm install bower --global
-
The app will look for the
PORT
environment variable to listen on a particular port. If none is found, it will default to port 8080 and the app will be accessible through your IP address and port or locally athttp://localhost:8080
. To use a different port (like the standard port 80), export thePORT
variable before running the app:export PORT=80
-
Use
node
ornodemon
to run the app:nodemon app.js
Note:
nodemon
is a utility that automatically checks for updates and restarts the node server, which is great for development. You can alternatively runnode app.js
but you will have to restart the server if you change any code. Runnpm install nodemon --global
to installnodemon
.
The following pin configuration is assumed, using the SparkFun GPIO Block (see image below):
GPIO Pin | Component | MRAA Pin (in code) |
---|---|---|
GP44 | Green LED | 31 |
GP45 | Yellow LED | 45 |
GP46 | Red LED | 32 |
GP47 | Red LED | 46 |
GP48 | Yellow LED | 33 |
GP49 | Green LED | 47 |
GP15 | Button tied high w/ 1K pull-down | 48 |
GP14 | Unused | 36 |