rgb led strip code example

Example 1: blynk rgb led strip

#define BLYNK_PRINT Serial


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

char auth[] = "********************************";

char ssid[] = "**********";
char pass[] = "*********";

void setup()
{
  Serial.begin(9600);

  Blynk.begin(auth, ssid, pass);
}

void loop()
{
  Blynk.run();
}

Example 2: blynk rgb led strip

#define pinRED 3
#define pinGREEN 5
#define pinBLUE 6

#define flag_esp 11

int value_red_esp;
int value_green_esp;
int value_blue_esp;

int red_esp;
int green_esp;
int blue_esp;

int value_red;
int value_green;
int value_blue;
int on_signal_esp;

int brightness_red;
int brightness_green;
int brightness_blue;

int red_color;
int blue_color;
int green_color;

void setup() {
  // put your setup code here, to run once:
  pinMode(pinRED, OUTPUT);
  pinMode(pinGREEN, OUTPUT);
  pinMode(pinBLUE, OUTPUT);
  pinMode(flag_esp,INPUT);
  
  Serial.begin(9600);
}

void loop() {
  // put your main code here, to run repeatedly:

  value_red_esp= analogRead(A0);
  value_green_esp= analogRead(A1);
  value_blue_esp= analogRead(A2);

  red_esp= map(value_red_esp, 0, 673, 0, 255);
  green_esp= map(value_green_esp, 0, 673, 0, 255);
  blue_esp= map(value_blue_esp, 0, 673, 0, 255);

  if( red_esp >= 254){
    red_esp = 255;
  }
   if( green_esp >= 254){
    green_esp = 255;
  }
 if( blue_esp >= 254){
    blue_esp = 255;
  }
  on_signal_esp = digitalRead(flag_esp);
  if( (on_signal_esp == 0)){
  red_color=0;
  blue_color=0;
  green_color=0;
  }
  else if ((on_signal_esp == 1)){
  red_color=red_esp;
  blue_color=blue_esp;
  green_color=green_esp;
  }

  analogWrite(pinRED, red_color);
  analogWrite(pinGREEN, green_color);
  analogWrite(pinBLUE, blue_color);
  
  Serial.print(on_signal_esp);
  Serial.print(" ");
  Serial.print(red_esp);
  Serial.print(" ");
  Serial.print(green_esp);
  Serial.print(" ");
  Serial.println(blue_esp);

  
  
}

Example 3: blynk rgb led strip

if( red_esp >= 254){
    red_esp = 255;
  }
   if( green_esp >= 254){
    green_esp = 255;
  }
 if( blue_esp >= 254){
    blue_esp = 255;

Tags:

Misc Example