lightthedreams
Published © GPL3+

Control LED RGB WS2812B using Bluetooth and Android

How to control LED RGB WS2812B (Neo Pixel/ Addressable LED) using Arduino, Bluetooth Modul HC05 and and Android Application made by MIT APP

BeginnerFull instructions provided19,176
Control LED RGB WS2812B using Bluetooth and Android

Things used in this project

Hardware components

Arduino UNO
Arduino UNO
×1
WS2812 Addressable LED Strip
Digilent WS2812 Addressable LED Strip
×1
HC-05 Bluetooth Module
HC-05 Bluetooth Module
×1

Software apps and online services

Arduino IDE
Arduino IDE
MIT App Inventor
MIT App Inventor

Hand tools and fabrication machines

Soldering iron (generic)
Soldering iron (generic)

Story

Read more

Schematics

Schematic

Code

Code

Arduino
#include <Adafruit_NeoPixel.h>
#ifdef __AVR__
#include <avr/power.h> 
#endif
#define LED_PIN    2
#define LED_COUNT 13
Adafruit_NeoPixel strip(LED_COUNT, LED_PIN, NEO_GRB + NEO_KHZ800);
int k;
int val;

void setup()
{
Serial.begin(9600);
#if defined(__AVR_ATtiny85__) && (F_CPU == 16000000)
  clock_prescale_set(clock_div_1);
#endif
  strip.begin();           
  strip.show();            
  strip.setBrightness(50); 
}

void loop()
{
  if (Serial.available())
  {
   val = Serial.read();
       if (val == 'R') //Rainbow
       {
        rainbow(10); 
       }
       if (val == 'r') // red
       {
        colorWipe(strip.Color(255, 0, 0), 50);    
       }
       if (val == 'g') // green
       {
        colorWipe(strip.Color(0, 255, 0), 50);    
       }
        if (val == 'b') // blue
       {
        colorWipe(strip.Color(0, 0, 255), 50);    
       }
        if (val == 'w') // white
       {
        colorWipe(strip.Color(255, 255, 255), 50); 
       }
        if (val == 'y') //yellow
       {
        colorWipe(strip.Color(255, 255, 0), 50); 
       }
        if (val == 'm') //magenta
       {
        colorWipe(strip.Color(255, 0, 255), 50); 
       }
        if (val == 'c') //cyan
       {
        colorWipe(strip.Color(0, 255, 255), 50); 
       }
        if (val == 'o') //off
       {
        colorWipe(strip.Color(0, 0, 0), 50); 
       }
  }  
}
  
void rainbow(int wait) { 
    for(long firstPixelHue = 0; firstPixelHue < 5*65536; firstPixelHue += 256) {
    for(int i=0; i<strip.numPixels(); i++) { 
    int pixelHue = firstPixelHue + (i * 65536L / strip.numPixels());
    strip.setPixelColor(i, strip.gamma32(strip.ColorHSV(pixelHue)));
    }
    strip.show(); 
    delay(wait);  
  }
}


void colorWipe(uint32_t color, int wait) {
  for(int i=0; i<strip.numPixels(); i++) { 
    strip.setPixelColor(i, color);         
    strip.show();                          
    delay(wait);                           
  }
}

Credits

lightthedreams

lightthedreams

8 projects • 17 followers
learn everyday from anywhere

Comments