Control WS2801 trough PWM

Hello,

I am using the NodeMCU Esp8266 Board including the Blynk and FastLED Lybrary. I Already got the LEDs and the Blynk setup in one Code working, and now i want to adjust the LED colors by Blynk and PWM. Could someone help me out there? This is my first Arduino/Board Project at all.

Thanks to all

#include "FastLED.h"
#define BLYNK_PRINT Serial


#include <ESP8266WiFi.h>
#include <BlynkSimpleEsp8266.h>

// You should get Auth Token in the Blynk App.
// Go to the Project Settings (nut icon).
char auth[] = "token";

// Your WiFi credentials.
// Set password to "" for open networks.
char ssid[] = "wlan ssid";
char pass[] = "pw";

////////////////////////////////////////////////////////////////////////////////////////////////////
//
// RGB Calibration code
//
// Use this sketch to determine what the RGB ordering for your chipset should be.  Steps for setting up to use:

// * Uncomment the line in setup that corresponds to the LED chipset that you are using.  (Note that they
//   all explicitly specify the RGB order as RGB)
// * Define DATA_PIN to the pin that data is connected to.
// * (Optional) if using software SPI for chipsets that are SPI based, define CLOCK_PIN to the clock pin
// * Compile/upload/run the sketch

// You should see six leds on.  If the RGB ordering is correct, you should see 1 red led, 2 green
// leds, and 3 blue leds.  If you see different colors, the count of each color tells you what the
// position for that color in the rgb orering should be.  So, for example, if you see 1 Blue, and 2
// Red, and 3 Green leds then the rgb ordering should be BRG (Blue, Red, Green).

// You can then test this ordering by setting the RGB ordering in the addLeds line below to the new ordering
// and it should come out correctly, 1 red, 2 green, and 3 blue.
//
//////////////////////////////////////////////////

#define NUM_LEDS 5

// Data pin that led data will be written out over
#define DATA_PIN 6
// Clock pin only needed for SPI based chipsets when not using hardware SPI
//#define CLOCK_PIN 8

CRGB leds[NUM_LEDS];

void setup() {
  // sanity check delay - allows reprogramming if accidently blowing power w/leds
  delay(2000);

  // Uncomment one of the following lines for your leds arrangement.
  // FastLED.addLeds<TM1803, DATA_PIN, RGB>(leds, NUM_LEDS);
  // FastLED.addLeds<TM1804, DATA_PIN, RGB>(leds, NUM_LEDS);
  // FastLED.addLeds<TM1809, DATA_PIN, RGB>(leds, NUM_LEDS);
  // FastLED.addLeds<WS2811, DATA_PIN, RGB>(leds, NUM_LEDS);
  // FastLED.addLeds<WS2812, DATA_PIN, RGB>(leds, NUM_LEDS);
  // FastLED.addLeds<WS2812B, DATA_PIN, GRB>(leds, NUM_LEDS);
  // FastLED.setBrightness(CRGB(255,255,255));
  // FastLED.addLeds<GW6205, DATA_PIN, RGB>(leds, NUM_LEDS);
  // FastLED.addLeds<GW6205_400, DATA_PIN, RGB>(leds, NUM_LEDS);
  // FastLED.addLeds<UCS1903, DATA_PIN, RGB>(leds, NUM_LEDS);
  // FastLED.addLeds<UCS1903B, DATA_PIN, RGB>(leds, NUM_LEDS);

  FastLED.addLeds<WS2801, 6, 8, RGB>(leds, NUM_LEDS);
  // FastLED.addLeds<SM16716, RGB>(leds, NUM_LEDS);
  // FastLED.addLeds<LPD8806, 9, 10, RGB>(leds, NUM_LEDS);

  // FastLED.addLeds<WS2801, DATA_PIN, CLOCK_PIN, RGB>(leds, NUM_LEDS);
  // FastLED.addLeds<SM16716, DATA_PIN, CLOCK_PIN, RGB>(leds, NUM_LEDS);
  // FastLED.addLeds<LPD8806, DATA_PIN, CLOCK_PIN, RGB>(leds, NUM_LEDS);
  // Debug console
  Serial.begin(9600);

  Blynk.begin(auth, ssid, pass);
  // You can also specify server:
  //Blynk.begin(auth, ssid, pass, "blynk-cloud.com", 8442);
  //Blynk.begin(auth, ssid, pass, IPAddress(192,168,1,100), 8442);
}

void loop() {
  leds[0] = CRGB(255, 0, 0);
  leds[1] = CRGB(0, 255, 0);
  leds[2] = CRGB(0, 255, 0);
  leds[3] = CRGB(0, 0, 255);
  leds[4] = CRGB(0, 0, 255);
  leds[5] = CRGB(0, 0, 255);
  FastLED.show();
  delay(1000);
  Blynk.run();
}

LIGHTING.ino (3.42 KB)

Hi.

You need to place your code in code tags so we can read the code.

Also, take a picture of his you have everything hooked up and post it.

What specifically would you like help with?

Hello,

I've added Code and Picture of my cabeling as a file.
I now just want to adjust the leds brightness and colors with the blynk app.

Thanks

Hi.

You need to place your code in code tags so we can read the code.

WS2801 is digitally controlled. You do not need to use an PWM on the Arduino to control the LED's.

You control the brightness by altering the data you send to the LED's.

// Per.

@CtrlAltElite

Now added the Code with code tags.

@Zapro

But the Blynk app can only outputs PWM Signals? Or am i wrong?

The app doesn't output PWM, it outputs a value. What you do with it is up to you :wink:

Dennis,

Do the lights work now? I saw your picture, but, really, to get the leds to work reliably you need to solder them together to the board.
i have reviewed your code. What you need to do is create some variables of stuff you want to change through your phone.

Do you want all the leds to switch to the same color, or, how do you want it to be split up?

Let’s start by assuming you want them to switch to all the same color first.

using fastled, you can change the colors of the leds easily by using hsv. (hue, which is color, saturation, which is how much white component there is, and value, which is how bright it is)

for(int i = 0; i < NUM_LEDS; i++){
    leds[i] = CHSV( hue, saturation, value);
}

Then, all you need to do is create three byte variables and set up the app to use those values.

Ok, This is my updated Code:

#include "FastLED.h"
#define BLYNK_PRINT Serial


#include <ESP8266WiFi.h>
#include <BlynkSimpleEsp8266.h>

// You should get Auth Token in the Blynk App.
// Go to the Project Settings (nut icon).
char auth[] = "a5d3b94c94f24e2092ce00f888f9b593";

// Your WiFi credentials.
// Set password to "" for open networks.
char ssid[] = "UPC47D7CE8";
char pass[] = "wppthsh6zvMh";

////////////////////////////////////////////////////////////////////////////////////////////////////
//
// RGB Calibration code
//
// Use this sketch to determine what the RGB ordering for your chipset should be.  Steps for setting up to use:

// * Uncomment the line in setup that corresponds to the LED chipset that you are using.  (Note that they
//   all explicitly specify the RGB order as RGB)
// * Define DATA_PIN to the pin that data is connected to.
// * (Optional) if using software SPI for chipsets that are SPI based, define CLOCK_PIN to the clock pin
// * Compile/upload/run the sketch

// You should see six leds on.  If the RGB ordering is correct, you should see 1 red led, 2 green
// leds, and 3 blue leds.  If you see different colors, the count of each color tells you what the
// position for that color in the rgb orering should be.  So, for example, if you see 1 Blue, and 2
// Red, and 3 Green leds then the rgb ordering should be BRG (Blue, Red, Green).

// You can then test this ordering by setting the RGB ordering in the addLeds line below to the new ordering
// and it should come out correctly, 1 red, 2 green, and 3 blue.
//
//////////////////////////////////////////////////

#define NUM_LEDS 5
// Data pin that led data will be written out over
#define DATA_PIN 6
//#define CLOCK_PIN 8

CRGB leds[NUM_LEDS];

BLYNK_WRITE(V1) //Slider RED Widget is writing to pin V1
{
  int pinValue = param.asInt(); 
   Serial.print("V1 Slider value is: ");
  Serial.println(pinValue);
}
BLYNK_WRITE(V2) //Slider GREEN Widget is writing to pin V1
{
  int pinValue = param.asInt(); 
   Serial.print("V2 Slider value is: ");
  Serial.println(pinValue);
}
BLYNK_WRITE(V3) //Slider BLUE Widget is writing to pin V1
{
  int pinValue = param.asInt(); 
   Serial.print("V3 Slider value is: ");
  Serial.println(pinValue);
}
BLYNK_WRITE(V4) //Slider WHITE Widget is writing to pin V1
{
  int pinValue = param.asInt();
   Serial.print("V4 Slider value is: ");
  Serial.println(pinValue); 
}

void setup() {
  // sanity check delay - allows reprogramming if accidently blowing power w/leds
  delay(2000);
  FastLED.addLeds<WS2801, 6, 8, RGB>(leds, NUM_LEDS);
  Serial.begin(9600);
  Blynk.begin(auth, ssid, pass);
  // You can also specify server:
  //Blynk.begin(auth, ssid, pass, "blynk-cloud.com", 8442);
  //Blynk.begin(auth, ssid, pass, IPAddress(192,168,1,100), 8442);
}

void loop() {
  Blynk.run();
  FastLED.show();
  delay(1000);
  for(int i = 0; i < NUM_LEDS; i++){
    leds[i] = CHSV( hue, saturation, value);
}

}

How do i now have to declare hue, saturation and value with the Blynk readouts? (They work)

Your code does not compile, how do you know if it works?

I've tested this Code and shows me a message that i need to declare hue saturation and value.

dennis03:
I've tested this Code and shows me a message that i need to declare hue saturation and value.

 leds[i] = CHSV( hue, saturation, value);

These are simply three variables that define the colour of your LED. You can make them just constants if you like. You declare them like you declare any other variable, that is the variable type followed by the name followed by the initial value.
Are you expecting the values to be filled in by something.

The values and how they relate to the colour are shown here HSL and HSV - Wikipedia

dennis, you have to declare the variables before setup. Then you have to set them to something. For testing initially, i would set all of them to 255. Your leds should be bright red. a let me know if that works.