The owLED Guessing Game
A Small Experiment with Node.JS, Arduino, Johnny Five, Sphero, Cylon.js, Socket.IO, Redis, and Angular.
What Is This?
Basically this is me playing with stuff.
What does it do?
This allows an Arduino or Spark Core to randomly blink two differently colored LED lights for a few seconds. When the lights stop blinking, the state of each LED (on or off) is communicated with any connected web client.
It is up to the user to guess which LEDs will be lit (or off) at the end of the blinking sequence. The user confirms the guess by clicking on the red & green buttons on the page served by the Node.JS application. In this case, the red and green buttons look like owl eyes.
Guessing correctly scores a point.
The history of the blinking sequences is stored in a Redis database, and the most recent 25 results can be viewed by the user (by clicking the hamburger icon in the upper left corner of the screen).
- Install Node.jS
- Install Redis
- Download/Clone this repository
npm installto fetch the dependencies
- Bonus Check out the sphero branch of this repo for extra Sphero functionality (only if you have a Sphero).
Test Mode - No Hardware Needed
node index.jsto start the server.
- Open a web browser to
- Click the Auto Blink checkbox and wait a few seconds.
- The Node console should output some information, and your browser window should update.
- Connect a Spark Core with 2 LEDs and a Pushbutton (see diagram below).
- Make sure it is running the voodoospark firmware.
index.js, comment out this line:
var owled = require('./server/owled-fake');
index.js, uncomment this line:
//var owled = require('./server/owled');
- Ensure the Spark Core is on and connected to the 'cloud' (pulsing cyan).
Spark Core Diagram
Basically the same setup as the spark core, but go to
/server/owled.js and comment out the Spark Core board init code (lines 10-15) and the Spark Core pins (lines 28-30).
Then uncomment the Arduino board init (line 19) and the Arduino pins (34-36)
Change the pin numbers depending on how you wired up your board.
Bonus Sphero Action
- 1. Check out the
spherobranch of this project.
- 2. Pair a Sphero to your computer via bluetooth. See the Cylon docs for more info.
- 3. Find the Sphero connection ID. On a Mac, do
ls /dev/tty.*and look for
tty.Sphero-ABC-DEFin the output.
/server/mysphero.jsand replace the Sphero id on line 17 with your own.
node index.jsand hopefully your Sphero will connect. (It may take a few tries).
- There is a 5 second calibration period to orient Sphero.
- Whenever a user guesses correctly and scores a point, Sphero will roll forward.