To join the CheerLights project, you need to build a display of the latest CheerLights color. The display can be a physical set of multicolored lights or a virtual display like a web page, widget, or app. In all cases, the displays read the latest CheerLights color using the CheerLights API.
CheerLights GitHub
Check out GitHub (CheerLights GitHub and the NotHans GitHub) for our latest examples using Arduino and different types of lighting displays and client libraries.
ThingSpeak Arduino / Particle Library
ThingSpeak has an official library for Arduino and Particle / Spark devices. Once you have installed the library, you can use have access to the latest CheerLights color by using the readStringField command on Arduino and Particle devices.
Library Installation
Arduino IDE
In the Arduino IDE, choose Sketch/Include Library/Manage Libraries. Click the ThingSpeak Library from the list, and click the Install button.
Particle / Spark IDE
In the Particle Web IDE, click the libraries tab, find “ThingSpeak”, and choose “Include in App”.
WLED
WLED is special firmware for ESP devices to run multicolor LED lights. Once installed, you can create cool effects, synchronize multiple devices, and build light shows.
cURL
To get the latest color name at the command line, type:
curl http://api.thingspeak.com/channels/1417/field/1/last.txt
Web Widgets
A Web widget is some HTML, JavaScript, and CSS to display the latest CheerLights color on your website, WordPress blog, or Tumblr site. This is an easy way for web developers to join the CheerLights project. To build a widget, you need to make an AJAX call to the CheerLights API, parse the response for the latest color, and set the color of an object with the color. field2 contains the HTML HEX color value of the latest color.
CheerLights Web Widget Links
- Color + Snow: https://cheerlights.com/widgets/snow.html
- Just Color: https://cheerlights.com/widgets/color.html
WordPress
To embed CheerLights web widgets on your WordPress site, use the “Shortcode” block in the editor and specify the width and height.
jQuery
Place code like this in the head of an HTML document to read the latest color from CheerLights and set the background color of the web page to that color.
$(document).ready(function() { $.getJSON('https://api.thingspeak.com/channels/1417/feed/last.json', function(data) { if (data.field2) { $("body").css("background-color", data.field2); } }); }
MATLAB
Using MATLAB you can read in the latest color or do analysis on CheerLights to discover popular colors and how long colors get displayed during the day. To use CheerLights with MATLAB, install the ThingSpeak Support Toolbox. Once you install the toolbox, you will have access to the “thingSpeakRead” function. This is what you will use to read the latest colors into MATLAB.
latestCheer = thingSpeakRead(1417, 'outputFormat', 'table'); currentColor = latestCheer.LastCheerLightsCommand