theterg / trafficlight-server

A node-js application for a Raspberry Pi to interactively control 3 lights via HTTP and websockets

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Trafficlight-server

A node.js application for a raspberry pi. A raspberry pi is plugged into 3 (or more) lights via GPIO pins. This project exposes the lights via a simple web/websockets/socket interface. Designed specifically for a traffic light, but could be expanded to any number of lights with unique names.

Endpoints (assuming hostname of 'raspberrypi'):

Server consumes the following websocket events:

  • 'turnOn' - payload: 'color'
    • color is a simple string ('red', 'yellow', 'green')
  • 'turnOff' - payload: 'color'
    • color is a simple string ('red', 'yellow', 'green')
  • 'toggle' - payload: 'color'
    • color is a simple string ('red', 'yellow', 'green')

Server emits the following websocket event:

  • 'update' - payoad: { 'color': color, 'value': value }
    • color is a simple string ('red', 'yellow', 'green')
    • value is an integer - 0 is off, 1 is on

About

A node-js application for a Raspberry Pi to interactively control 3 lights via HTTP and websockets


Languages

Language:JavaScript 91.7%Language:CSS 8.3%