Giter Site home page Giter Site logo

tessel-nfl's Introduction

tessel-nfl

Tessel NFL

View on YouTube

Ever since I watched the World Cup at a BW3, and saw a Budweiser Red Light, I was fascinated with how it worked. When a team scored a goal on TV, the Red Light instantly lit up! Having worked with Firebase and websockets for a bit, I wanted to make that happen.

I did some research and noticed that they used an Electric Imp and an app to control which game they wanted the Red Light to be activated on. So cool.

After I pestered my wife to buy me a tessel for a while, I finally got one for my birthday! I instantly ordered the relay module and went to work. My favorite sport now is NFL football, and I thought how cool it would be to wire up the tessel to a light in my house for my annual Super Bowl party.

I looked around for some streaming NFL score API's, but all of them were a few grand a month. Yah, no. I eventually stumped upon the NFL's basic XML feed and decided to use that. When I synced it up to the tessel, the XML to JSON module was taking roughly 5 seconds to process every call, which was unacceptable (this thing needs to be as real time as I can get! Otherwise what's the purpose...). I finally found a related JSON API, and even though it isn't formatted well and is super basic, it works just great once everything is all dialed in! I basically poll it every second and check the current score against the previously checked score, amongst other logic. And while it's not streaming/websockets, I can poll it every second without the NFL penalizing me and it accomplishes what I was looking for.

Description

A script for the tessel that uses the NFL's ScoreScript JSON feed to check the scores for a specific game, and trigger an attached relay on a score.

Prerequisites

While you can port this script quite easily to a non-tessel node script, it's made to work with the tessel and it's relay module. If you don't have the relay module, don't worry -- it'll still work, but it'll be quite more boring watching a command line when someone scores a game. Feel free to trigger something cooler than a light!

Installation

This is a great bit of starter code to start playing around with your tessel. Download the code, run nom install, then plugin your tessel and run tessel push index.js. You are now good to go! Easy peasy.

Usage & Options

This script is pretty much ready to go. I placed variables at the top of the file so that they are easy to modify depending on what you want to do.

  • relayChannel: Sets the relay channel to trigger.
  • checkInterval: How often to check the API for a score change, in milliseconds. A value of 1000 seems to work pretty well.
  • checkLongInterval: How often to check the API before the game starts or at halftime, in milliseconds. I think checking once a minute works well.
  • toggleInterval: How fast the relay pulses on a trigger, in milliseconds.
  • toggleCount: How often the relay should pulse. Make sure this is an even number so it goes back to the value before the relay is triggered.
  • consoleActive: Whether to output logs to the console on actions.
  • url: The URL to use of the API. This may be different if the NFL game is a regular season game vs. a postseason game.
  • activeIndex: Which index of the JSON response to activate for the game. I initially assigned this to 11 for the Super Bowl. The Pro Bowl this year should have the 10 index if you want to test this beforehand (I'm not sure if they will update the API as quick for the Pro Bowl, but for a real game it updates very quickly).

License

WTFPL - Do what you want with it and have fun! If you make this work for different sports or API's, please let me know so I can post a link up to it! This script would work great for hockey, soccer, and football.

If you like this script and are feeling philanthropic, please donate funds to My Alzheimer's Walk Page for Team Shust. It's a fantastic organization and your donation will go a long way in finding a cure for a horrible disease.

tessel-nfl's People

Contributors

markshust avatar

Stargazers

 avatar  avatar Zvi avatar Martin Blanchette avatar Mark Gukov avatar Gustavo De Mari Pereira avatar Mike Mackenzie avatar  avatar

Watchers

 avatar James Cloos avatar  avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.