Cheerlights RGB LED Control

Photon connected Cheerlights via ThingSpeak (ThingSpeak.h library), Tweets containing “@cheerlights color” will change color. I have ‘calibrated’ the RGB display colors using Tinker from my phone (all good). I am using D0, D1 and D2 for R, G, and B pins on LED (per drawing). Using values from 0 to 255 to determine output from analogWrite for each pin (see modified MathLab code below).

How do I see each analogWite output on terminal from pins D0, D1 and D2? (have installed CLI) I would like to confirm the 0-255 output for each pin

Code on MacOS, flashed to Photon.

/*
  CheerLights
  
  Reads the latest CheerLights color on ThingSpeak, and sets a common anode RGB LED on digital pins 0, 1, and 2.
  On Spark core, the built in RGB LED is used
  Visit http://www.cheerlights.com for more info.

  ThingSpeak ( https://www.thingspeak.com ) is an analytic IoT platform service that allows you to aggregate, visualize and analyze live data streams in the cloud.
  
  Copyright 2017, The MathWorks, Inc.

  Documentation for the ThingSpeak Communication Library for Particle is in the doc folder where the library was installed.
  See the accompaning licence file for licensing information.
*/

#include "ThingSpeak.h"

// Make sure that you put a 330 ohm resistor between the Particle
// pins and each of the color pins on the LED.

int pinRed   = D0;
int pinGreen = D1;
int pinBlue  = D2;

TCPClient client;


/*
  This is the ThingSpeak channel number for CheerLights
  https://thingspeak.com/channels/1417.  Field 1 contains a string with
  the latest CheerLights color.
*/
unsigned long cheerLightsChannelNumber = 1417;

void setup() {
  ThingSpeak.begin(client);
  pinMode(pinRed, OUTPUT);
  pinMode(pinGreen, OUTPUT);
  pinMode(pinBlue, OUTPUT);
  
}

void loop() {
  // Read the latest value from field 1 of channel 1417
  String color = ThingSpeak.readStringField(cheerLightsChannelNumber, 1);
  setColor(color);

  // Check again in 5 seconds
  delay(5000);
}

// List of CheerLights color names
String colorName[] = {"none","red","pink","green","blue","cyan","white","warmwhite","oldlace","purple","magenta","yellow","orange"};

// Map of RGB values for each of the Cheerlight color names
int colorRGB[][3] = {     0,  0,  0,  // "none"
                        255,  0,  0,  // "red"
                        255,192,203,  // "pink"
                          0,255,  0,  // "green"
                          0,  0,255,  // "blue"
                          0,215, 75,  // "cyan",
                        255,255,255,  // "white",
                        255,223,223,  // "warmwhite",
                        255,223,223,  // "oldlace",
                        128,  0,128,  // "purple",
                        255,  0,255,  // "magenta",
                        255,255,  0,  // "yellow",
                        255, 49,  0}; // "orange"};

void setColor(String color)
{
  // Look through the list of colors to find the one that was requested
  for(int iColor = 0; iColor <= 12; iColor++)
  {
    if(color == colorName[iColor])
    {
      // When it matches, look up the RGB values for that color in the table,
      // and write the red, green, and blue values.

	  RGB.control(true);
	  RGB.color(colorRGB[iColor][0], colorRGB[iColor][1], colorRGB[iColor][2]);
	  
      analogWrite(pinRed,colorRGB[iColor][0]);
      analogWrite(pinGreen,colorRGB[iColor][1]);
      analogWrite(pinBlue,colorRGB[iColor][2]);

      return;
    }
  }
}

UPDATE- Changed pin id’s to D0, D1 and D2, so far so good…

Have a look at ‘Serial’ in the docs :wink:

You know, you can edit your previous posts, but for now I’ve updated your code in post #1 accordingly :wink:

What drawing?