← Back to Coding
Loading…
Live — updates every 15 seconds

What is CheerLights?

CheerLights is an open IoT project created by Hans Scharler that lets anyone in the world change the color of connected lights simultaneously by posting to social media or sending a message to the CheerLights API. The idea is simple: everyone's lights change together, creating a shared, synchronized experience across the globe.

The current color is published to a public API channel on ThingSpeak, a free IoT data platform. Anyone can read the latest color and use it however they like.

How It's Used on This Site

  1. When the homepage loads, a small JavaScript snippet fires a request to the ThingSpeak API.
  2. The API returns the most recent CheerLights color as a hex value (e.g. #ff0000) in a JSON response.
  3. The color is applied to the live swatch on the homepage and reflected in the accent badge in the hero section.
  4. On this page, the color refreshes automatically every 15 seconds so you can watch it change in real time.

The Code

The fetch is a single jQuery call — simple and lightweight:

// Fetch latest CheerLights color from ThingSpeak
$.getJSON(
  'https://api.thingspeak.com/channels/1417/feed/last.json',
  function(data) {
    if (data.field1 && data.field2) {
      // field1 = color name, field2 = hex value
      document.getElementById('cl-name').textContent = data.field1;
      document.getElementById('cl-hex').textContent  = data.field2;
      document.getElementById('cl-swatch').style.background = data.field2;
    }
  }
);

Change the Color

Want to change the CheerLights color for everyone? Post a tweet or message to the CheerLights community with a color name — like "@cheerlights red" or "@cheerlights warmwhite" — and the whole network updates within seconds.

Supported colors include: red, green, blue, cyan, white, warmwhite, purple, magenta, yellow, orange, pink, and more.

Learn more at cheerlights.com