Techatronic
Published

WS2811 with Arduino bluetooth control

Pixel light control using Arduino

IntermediateFull instructions provided563
WS2811 with Arduino bluetooth control

Things used in this project

Hardware components

Arduino UNO
Arduino UNO
×1
HC-05 Bluetooth Module
HC-05 Bluetooth Module
×1
NeoPixel Ring: WS2812 5050 RGB LED
Adafruit NeoPixel Ring: WS2812 5050 RGB LED
×1

Software apps and online services

Arduino IDE
Arduino IDE

Hand tools and fabrication machines

Soldering iron (generic)
Soldering iron (generic)

Story

Read more

Schematics

circuit

Code

code

C/C++
code for ws2811
#include <FastLED.h>

#define LED_PINA    13

#include <SoftwareSerial.h>

SoftwareSerial mySerial(4, 5); // RX, TX


#define NUM_LEDS  100

CRGB leds[NUM_LEDS];
void setup() {
  
   FastLED.addLeds<WS2812, LED_PINA, GRB>(leds, NUM_LEDS);

 
  mySerial.begin(9600);
Serial.begin(9600);

}

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

int q;
  
if(mySerial.available()>0)

{
  char m = mySerial.read();
 Serial.println(m);
 
//  Serial.println(t);
  switch (m)
  {





// warm slowly pattern start here (RED)
    
  case 'A':
  while(1)
  {
if(mySerial.available()>0)
{  
break; }
 for(q=0; q<=90; q++){
    if(mySerial.available()>0)
{  
break; }
  for ( i = 0; i <=NUM_LEDS; i++ )
{   
  
  leds[i] = CRGB ( 255,0, 0);
    
  if(mySerial.available()>0)
{  
break; }}
FastLED.setBrightness(  q);
FastLED.show();
delay(d);  
 if(mySerial.available()>0)
{  
break; }
   }

   

for(q=90; q>=0; q--){
    if(mySerial.available()>0)
{  
break; }
  for ( i = 0; i <=NUM_LEDS; i++ )
{   
  
  leds[i] = CRGB ( 255,0, 0);
    
  if(mySerial.available()>0)
{  
break; }}
FastLED.setBrightness(  q);
FastLED.show();
delay(d);  
 if(mySerial.available()>0)
{  
break; }
   }



if(mySerial.available()>0)
{  
break; }

}



// warm slowly pattern end here (RED)

// warm slowly pattern start here (BLUE)




case 'B':
  while(1)
  {

 for(q=0; q<=90; q++){
    
  for ( i = 0; i <=NUM_LEDS; i++ )
{   
  
  leds[i] = CRGB ( 0,255, 0);
    
  }
FastLED.setBrightness(  q);
FastLED.show();
delay(d);  
 
   }

   

for(q=90; q>=0; q--){
    
  for ( i = 0; i <=NUM_LEDS; i++ )
{   
  
  leds[i] = CRGB ( 0,255, 0);
    
 }
FastLED.setBrightness(  q);
FastLED.show();
delay(d);  
 
   }





}

Credits

Techatronic

Techatronic

72 projects • 126 followers
Electronic engineer

Comments