Project in progress
Programable LEDstrip Module 1.0, 2.0

Programable LEDstrip Module 1.0, 2.0

A LED strip development multipurpose module

  • 2,502 views
  • 0 comments
  • 6 respects

Components and supplies

Necessary tools and machines

09507 01
Soldering iron (generic)
Vernier Caliper

Apps and online services

About this project

Hello everyone, this is my first project here as well as my first intermediate Arduino project. Everything started when I bought the cheap LED strip a while back soon after soon I started getting curious whether I could control it with my computer. That's when I first got introduced to and started working with Arduino.

In this project, I will show you through my full build.

Version 1

First, The circuit I begun with was very straight forward. I used Arduino NANO R3 for it's compact size. Then connecting an IR receiver module and the WS2812B LED strip like shown below in Diagram 1.

Now coming to the code, first thing you need collecting the IR code emitted by your remote. That could be done by loading the following code on your Arduino and writing down the hex codes belonging to each button on the remote. You'll need IRremote library installed to preform that.

#include <boarddefs.h>
#include <IRremote.h>
#include <IRremoteInt.h>
#include <ir_Lego_PF_BitStreamEncoder.h>
int type = -1;

int RECV_PIN = 10;
IRrecv irrecv(RECV_PIN);
decode_results results;


void setup()
{
Serial.begin(9600);
irrecv.enableIRIn(); // Start the receiver
}


void loop()
{
if (irrecv.decode(&results))
{
Serial.println(results.value, HEX);
irrecv.resume(); // Receive the next value
}

delay(100);
}

Once done with that, We start with main sketch. Here I did struggle a lot it in the beginning. My issue was how to have a running LED light effect and interrupting it at anytime by IR signal reading coming from the remote, or by serial input or Bluetooth which I will discuss later. After a lot of research and understanding the concept explained in Several Things At The Time and applying it in my code. The way I applied it was by making a LED mode function, simply that is an infinite loop function that drives the LEDs in pattern using Adafruit NeoPixel library. Each mode function has two things in common, first is the alternative of delay() function that utilize the "state machine" concept to allow various activities or function to be held or called at same time. Second is the function that accept interrupts. Using that method is how LED strip module works. Bellow is a sample code.

#include <boarddefs.h>
#include <IRremote.h>
#include <IRremoteInt.h>
#include <ir_Lego_PF_BitStreamEncoder.h>
#include <Adafruit_NeoPixel.h>

#define Button0 0xFF6897 // Hex code of button 0

#define PIN 6
#define NUMPIXELS 30 // Number of LEDs used
Adafruit_NeoPixel pixels(NUMPIXELS, PIN, NEO_GRB + NEO_KHZ800);

#define ButtonNum 1 // number of buttons
int RECV_PIN = 10;
IRrecv irrecv(RECV_PIN);
decode_results results;

long int CODES[ButtonNum] = {Button0}; // Array of all the Hex codes

int interval = 100;
unsigned long previousMillis = 0;
unsigned long currentMillis = 0;

void setup() {
pixels.begin(); // INITIALIZE NeoPixel strip object (REQUIRED)
Serial.begin(9600);
irrecv.enableIRIn(); // Start the receiver
}


void loop() {

unsigned long currentMillis = millis();
if (currentMillis - previousMillis >= interval) {
previousMillis = currentMillis;
findCode();
}
}

void findCode() { // Function that accepts interrupts
if (irrecv.decode(&results)) {
if (exist(results.value, CODES, ButtonNum)) {
LEDMODE(results.value); // calls mode
}
irrecv.resume();
}
}


bool exist(long int compareValue, long int arrayName[], int arraySize) {
irrecv.resume();
for (int x = 0; x < arraySize; x++) {
if (arrayName[x] == compareValue) {
return true;
}
}
return false;
}


void LEDMODE(long int code)
{
irrecv.resume();
switch(code){
case Button0: blinkingstar();
break;

// case ?? : OTHERMODES();
// break;


}
}

void blinkingstar(){
while(true){
currentMillis = millis();
if (currentMillis - previousMillis >= interval) {
previousMillis = currentMillis;
for(int x=0;x<(NUMPIXELS/15);x++){
int i = rand() % NUMPIXELS;
pixels.setPixelColor(i, pixels.Color(255, 255, 255));
}
pixels.show();
findCode();
}
pixels.clear();
}
}

In code above demonstrates the concepts I spoke about using one LED mode function. From this point I let my imagination lead by making several other mode functions enough to fit my remote.

Right after that I had everything working the way I wanted, I was not satisfied yet. I wanted a more compact and portable device, soon after I started researching into taking my design from the breadboard to PCB. It was sort of straight forward when it comes to making the connections. I used EasyEDA designer to make the PCB, and fabricated it using JLCpcb fabricating services. The result I ended up with after soldering everything together was like the following.

And to finish it. I design and 3D printed an enclosure, added threaded insert nut and screws to wrap it all up and make it look slightly better.

At this point the module was working fine. I even decided to create a windows remote application using Visual Studio 2019 to control the module via USB cable as an other alternative to control the LED strip module. But since I am not any good in C# the application is not the best, briefly how it work is by connected to desired serial port then sending serial data to the Arduino where it will decode data sent to do certain tasks like changing modes, setting RGB colors and even setting up new buttons from different remotes !

Version2

But still I was not happy, I believed that I could do better. Coming back to my sketch and breadboard, I decided that it should have music responsive modes.

After some more research on how I am going to apply that into my current module. Obviously I needed some sort of a microphone or a sound sensor, so for its low cost and small size the KY-038 Sound Sensor Module was the choice, also added in 3 buttons. So like shown in Diagram bellow show, I connected A0 pin on Arduino to analog pin on sound module, and pin 7, 8, 9 to the push buttons.

Now the fun part, coding. The output from KY-038 Module is a direct microphone signal as voltage value that is altered by the resistance of potentiometer, so what my approach was to get every two consecutive values and find the difference between them, as sound is played around the difference will increase thus it can trigger sound mode functions in different ways. Since the difference of the readings on its own is not suitable in every situation therefore I have added a variable called sensitivity and used two buttons to increase or decrease it. Also to handle all button functions I used ezButton Library.

To run both normal LED modes and sound modes on the Arduino, I had a main mode which is the usual LED modes, and secondary sound modes to alternate between them using a long mode button click (5sec click). Some might ask why don't I alternate them using the remote button instead, eventually that was my first plan, but due to some limitations in interval size for successful IR signal receival is around >75 for successful signal receival. While in sound mode function the interval is below that value, causing the remote to stop working. I found interval of 50ms suitable for sound modes.

int sensorPin = A0;
int Compare[2];
int i = 0;
int SoundInBoosted;
int sensitivity = 1;
int SoundInterval = 50;
bool soundmode = true;
int soundmodecall = 0;

void SoundMode(){
soundmode = true;
while(soundmode){
buttonUp.loop();
buttonDown.loop();
buttonMode.loop();

int inputValue = analogRead(sensorPin);
Compare[i] = inputValue;
i++;

if(i>1) // Finding the difference
{
SoundInBoosted = abs(Compare[0] - Compare[1]) * sensitivity;
SoundModeList(soundmodecall,SoundInBoosted);
i = 0;
}

if(buttonUp.isPressed()){ // Checking for UP button
Serial.println("The button Up is pressed");
if(sensitivity <= 201){
sensitivity += 5;
}
}

if(buttonDown.isPressed()){ // Checking for Down button
Serial.println("The button Down is pressed");
if(sensitivity > 1){
sensitivity -= 5;
}
}

if(buttonMode.isPressed()){ // Checking for Mode button
Serial.println("mode button pressed");
M_button_pressed = millis();
}else if(buttonMode.isReleased()){
M_button_released = millis();
if(M_button_released - M_button_pressed >= 3000) // If button was released
{ // in more than 3 sec return
Serial.println("Go to Remote mode"); // to main mode
soundmode = false;
}else{
if(soundmodecall < 6){ // Else go to next sound mode
soundmodecall++;
}else{
soundmodecall = 0;
}
}
}

delay(SoundInterval);
}
}


void SoundModeList(int count, int soundinput)
{
switch(count){

case 0: LEDSoundResponse_blue(soundinput);
break;

case 1: OTHER MODES(soundinput);
break;

}
}

void LEDSoundResponse_blue(int x){
pixels.clear();
int limit = x / (1000 / NUMPIXELS);
G = 0;
B = 1;
R = 0;
for(int i=0;i<=limit;i++){
if(B>=100){R += 10;}
pixels.setPixelColor(i, pixels.Color(R, G, B));
pixels.show();
B += 8;
}
}

Now modify findCode() function to switch between modes and to accept button interrupts. Also adding new function to shift between normal modes

void findCode() {
buttonMode.loop();
buttonUp.loop();
buttonDown.loop();

if (irrecv.decode(&results)) // look for IR signal
{
if (exist(results.value, CODES, ButtonNum))
{
LEDMODE(results.value); // calls mode
}
irrecv.resume();
}

if(buttonMode.isPressed()){
Serial.println("mode button pressed");
M_button_pressed = millis();
}else if(buttonMode.isReleased()){
M_button_released = millis();
if(M_button_released - M_button_pressed >= 3000){ // If button was released
Serial.println("Go to sound mode"); // in more than 3 sec return
SoundMode(); // to main mode
}else{
if(buttonshift < 1){
buttonshift++;
}else{
buttonshift = 0;
}
ButtonSwitch(buttonshift); // Else go to next LED mode
}
}

if(buttonUp.isPressed()){ // increase interval
if(interval <= 300){
interval += 50;}
}else if(buttonDown.isPressed()){ // decrease interval
if(interval > 50){
interval -= 50;
}
}
}

void ButtonSwitch(int z)
{
switch(z){

case 0: blinkingstar();
break;

// case 1: OTHER MODES();
// break;

}
}

void blinkingstar(){
buttonshift = 0;
while(true){
currentMillis = millis();
if (currentMillis - previousMillis >= interval) {
previousMillis = currentMillis;
for(int x=0;x<(NUMPIXELS/15);x++){
int i = rand() % NUMPIXELS;
pixels.setPixelColor(i, pixels.Color(255, 255, 255));
}
pixels.show();
findCode();
}
pixels.clear();
}
}

Once I became happy with the code, I went straight to design the PCBs and fabricate them. Last minute decision was to add female pin header connection to attach HC-05 Bluetooth module for further control options, for example using mobile phone app, also added another female pin header connection to digital pin 11 to allow me to add electronics or sensors for extra features in the future. Finally I designed an enclosure and Printed it to fit the new PCB. Following pictures shows how things were looking at the end.

Improvements

Now being satisfied with end results, but still room for improvements like.

  • Strengthen IR signal, since it is not so good from inside the enclosure.
  • Reduce interval required for successful IR signal receival.
  • Find a Better way to mount the push buttons to enclosure.
  • Write code for Bluetooth control (I have not made it yet) and an application to control it.
  • Make it smaller in size.

Potential uses

  • Ordinary LED strip for your room
  • For your car
  • Burglar LED alarm ( turn on a LED effect if sound detect )
  • Attach a sensor and code it to do something cool
  • Using a bunch them and the right interface, you could make a LED light system

Disclaimer

Not the entire code is mine, I had inspiration from all over the internet. Also it is far from prefect since I am kind of new to coding too. I would love helpful criticism, new ideas to Improve it or uses for it, and hopefully someone would benefit from it.

Code

LEDstripC/C++
Code used for version 2
#include <boarddefs.h>
#include <IRremote.h>
#include <IRremoteInt.h>
#include <ir_Lego_PF_BitStreamEncoder.h>
#include <Adafruit_NeoPixel.h>
#include <ezButton.h>

ezButton buttonUp(7);
ezButton buttonDown(8);
ezButton buttonMode(9);
unsigned long M_button_pressed;
unsigned long M_button_released;

#define Button0  0xFF6897
#define Button1  0xFF30CF
#define Button2  0xFF18E7
#define Button3  0xFF7A85
#define Button4  0xFF10EF
#define Button5  0xFF38C7
#define Button6  0xFF5AA5
#define Button7  0xFF42BD
#define Button8  0xFF4AB5
#define Button9  0xFF52AD
#define Bhun  0xFF9867
#define B200  0xFFB04F
#define Bplus  0xFFA85F
#define Bminus  0xFFE01F
#define Bchplus 0xFFE21D
#define Beq 0xFF906F
#define Bright 0xFF02FD
#define Bleft 0xFF22DD
#define Bplay 0xFFC23D
#define Bchminus 0xFFA25D
#define Bch 0xFF629D

#define PIN 6 
#define NUMPIXELS 30
Adafruit_NeoPixel pixels(NUMPIXELS, PIN, NEO_GRB + NEO_KHZ800);

int RECV_PIN = 5;
IRrecv irrecv(RECV_PIN);
decode_results results;

long int CODES[21] = {Button0, Button1, Button2, Button3, Button4, Button5,                            Button6, Button7, Button8, Button9, Bhun, B200, Bplus,                           Bminus, Bchplus, Beq, Bright, Bleft, Bplay, Bchminus,                             Bch};
long int NewCodes[21];
long int NewCode;
int N = 0;
String data;
char d;
int buttonshift = 0;

bool modeloop = true;
int R = 0;
int G = 0;
int B = 255;

int sensorPin = A0;
int Compare[2]; 
int i = 0;
int SoundInBoosted;
int sensitivity = 1;
int SoundInterval = 50;
bool soundmode = true;
int soundmodecall = 0;

int interval = 100;
unsigned long previousMillis = 0;
unsigned long currentMillis = 0;

void setup() {
  pixels.begin(); // INITIALIZE NeoPixel strip object (REQUIRED)
  Serial.begin(9600);
  irrecv.enableIRIn(); // Start the receiver
  buttonUp.setDebounceTime(50); 
  buttonDown.setDebounceTime(50);
  buttonMode.setDebounceTime(50); 
}


void loop() {
    
      unsigned long currentMillis = millis();
      if (currentMillis - previousMillis >= 100) {
        previousMillis = currentMillis;
        findCode();
      }    
}
//=============================================================================//======= COLORS ==============================================================//================================

 
void ColorFadeFunction(bool r, bool g, bool b, bool UpOrDown, int L_1, int L_2, int counter){ // only one at time
  if(UpOrDown == true){
      if(r == true){
        if(R<L_2){R+=counter;}
        else {R = L_1;}
      }else if(g == true){
          if(G <L_2){G+=counter;}
          else{G = L_1;}
      }else if(b == true){
          if(B <L_2){B+=counter;}
          else{B = L_1;}
       }
  }
  if(UpOrDown == false){
      if(r == true){
        if(R>=L_1){R-=counter;}
        else {R = L_2;}
      }else if(g == true){
          if(G>=L_1){G-=counter;}
        else {G = L_2;}
      }else if(b == true){
          if(B>=L_1){B-=counter;}
        else {B = L_2;}
       }
  }
  
}





//=================================================================================LED SOUND FUNCTIONS======================================================================================

void SoundMode(){
  
  soundmode = true;
  while(soundmode){
    buttonUp.loop(); 
    buttonDown.loop();
    buttonMode.loop(); 
    int inputValue = analogRead(sensorPin);
    Compare[i] = inputValue;
    i++;

  
    if(i>1)
    {
     SoundInBoosted = abs(Compare[0] - Compare[1]) * sensitivity;
     Serial.print("Input Modified difference: ");
     Serial.print(SoundInBoosted);
     Serial.print(", ");
     Serial.print("Sensitivity: ");
     Serial.print(sensitivity);
     Serial.print(", ");
     Serial.print("count: ");
     Serial.print(soundmodecall);
     Serial.print(", ");
     Serial.print("Threshold: ");
     Serial.println(inputValue);
     SoundModeList(soundmodecall,SoundInBoosted);
     i = 0;
    }  
  
    if(buttonUp.isPressed()){
      Serial.println("The button Up is pressed");
      if(sensitivity <= 201){
        sensitivity += 5;
      }
    }
  
    if(buttonDown.isPressed()){
      Serial.println("The button Down is pressed");
      if(sensitivity > 1){
        sensitivity -= 5;
      }
    }

  if(buttonMode.isPressed()){
      Serial.println("mode button pressed");
      M_button_pressed = millis();
  }else if(buttonMode.isReleased()){
    M_button_released = millis();
    if(M_button_released - M_button_pressed >= 3000)
    {
      Serial.println("Go to Remote mode");
      soundmode = false;
    }else{
        if(soundmodecall < 6){
          soundmodecall++;
        }else{
          soundmodecall = 0;
        }
     }
  }
      
    delay(SoundInterval);
    }
}


//=========================================================================LED REMOTE FUNCTIONS=================================================================================

void findCode() {
  buttonMode.loop();
  buttonUp.loop();
  buttonDown.loop();
  if (irrecv.decode(&results)) 
  {
    if (exist(results.value, CODES, 21)) 
    {
      LEDMODE(results.value); // calls mode
    }
    else if (exist(results.value, NewCodes, 21)) 
    {
      NewInBtn(results.value, NewCodes, 21);
    }
    irrecv.resume(); 
       
  }else if (Serial.available() > 0){
    SerialIn();
    }
  
  if(buttonMode.isPressed()){
      Serial.println("mode button pressed");
      M_button_pressed = millis();
  }else if(buttonMode.isReleased()){
    M_button_released = millis();
    if(M_button_released - M_button_pressed >= 3000){
      Serial.println("Go to sound mode");
      SoundMode();
      }else{
        if(buttonshift < 18){
          buttonshift++;
        }else{
          buttonshift = 0;
        }
        ButtonSwitch(buttonshift);
     }
  }
  
  if(buttonUp.isPressed()){
      if(interval <= 300){
       Serial.println("Interval up");
        interval += 50;}
  }else if(buttonDown.isPressed()){
      if(interval > 50){
        Serial.println("Interval down");
        interval -= 50;
      }
    }
}

int exist(long int compareValue, long int arrayName[], int arraySize) {
  irrecv.resume();
  for (int x = 0; x < arraySize; x++) {
    if (arrayName[x] == compareValue) {
      return true;
    }
  }
  return false;
}

void upinterval()
{
  if(interval<300){
      interval+=50;
  }
}

void downinterval()
{
 if(interval>100)
    interval-=100; 
}

//=========================================================================LED SERIAL FUNCTIONS==================================================================================

void IR_NewBtn(int N) // 
{
  bool newloop = true;
  while(newloop)
  {
    if (irrecv.decode(&results)) 
    {
     NewCode = results.value;
     NewCodes[N] = NewCode;
     newloop = false;
    }
    delay(100);
  }
  
  irrecv.resume();
  for(int x=0;x<=10;x++)
  {
  Serial.println("Z"); // not working
  delay(200);
  }
 
}

void setRGB(String x)
{
  String rstring = " ";
  String gstring = " ";
  String bstring = " ";

  rstring = x.substring(0,3);
  gstring = x.substring(3,6);
  bstring = x.substring(6);

  R = rstring.toInt();
  G = gstring.toInt();
  B = bstring.toInt();
  
}

//=========================================================================LED MODE LISTS========================================================================================

void SoundModeList(int count, int soundinput)
{
    switch(count){

              case 0: LEDSoundResponse_blue(soundinput);
                       break;
                        
              case 1: LEDSoundResponse_red(soundinput);
                        break;

              case 2: LedMidSoundResponse_red(soundinput);
                        break;

              case 3: LedMidSoundResponse_blue(soundinput);
                        break;

               case 4: SoundLEDFlash(soundinput);
                        break;

              case 5: SoundRedFade(soundinput);
                        break; 

              case 6: Sound_blinkingstar(soundinput);
                            break;

    }
}



void LEDMODE(long int code)
{ 
  irrecv.resume();
  switch(code){
              case Button0: R = 255;
                            G = 255;
                            B = 255;
                            whitejump();
                            break;
              
              case Button1: redneonmove();   
                            break;
              
              case Button2: blueneonmove();
                            break;
              
              case Button3: greenmove();
                            break;
              
              case Button4: redflash();
                            break;
              
              case Button5: B = 255;
                            blueflash();
                            break;
              
              case Button6: redsplitmove();
                            break;
              
              case Button7: bluesplitmove();
                            break;
              
              case Button8: B = 255;
                            redyellowsplitmove();
                            break;
              
              case Button9: redblueflash();
                            break;
                
              case Bhun: chasing();
                         break;
              
              case B200: beam();
                         break;

              case Beq: beamV2();
                        break;
              
              case Bchplus: kill();
                            break;

              case Bplus: upinterval();
                          break;

              case Bminus: downinterval();
                           break;

              case Bright: purpledot();
                           break;

              case Bplay: splitpaintmove();
                           break;

              case Bchminus: Colorfade();
                             break;

              case Bch: Fadingblueneon();
                        break;

              case Bleft: blinkingstar();
                          break;
                           
        }
}


void SerialIn()
{
  String x;  
  if(Serial.available())
  {
    data = Serial.readString();
    d = data.charAt(0);
    switch(d){

              case '0': kill();
                        break;
                        
              case '1': Colorfade();
                        break;

              case '2': Fadingblueneon();
                        break;

              case '3': splitpaintmove();
                        break;

               case '4': blinkingstar();
                        break;

              case '5': purpledot();
                        break;

               case '6': beamV2();
                        break;
                        
               case '7': chasing();
                         break;

               case '8': beam();
                         break;
                        
              case '9': whitejump();
                            break;
              
              case 'A': redneonmove();   
                            break;
              
              case 'B': blueneonmove();
                            break;
              
              case 'C': greenmove();
                            break;
              
              case 'D': redflash();
                            break;
              
              case 'E': blueflash();
                            break;
              
              case 'F': redsplitmove();
                            break;
              
              case 'G': bluesplitmove();
                            break;
              
              case 'H': redyellowsplitmove();
                            break;
              
              case 'I': redblueflash();
                            break;
              
              case 'S': x = data.substring(1);
                        interval = x.toInt();
                        break;

               case 'R': x = data.substring(1);
                         setRGB(x);
                         break;

             case 'N':  x = data.substring(1);
                        N = x.toInt();
                        IR_NewBtn(N); 
                        break;         
                                    
        }    
  }
}

void NewInBtn(long int compareValue, long int arrayName[], int arraySize)
{
  int z;
  for (int x = 0; x < arraySize; x++) {
    if (arrayName[x] == compareValue) {
      z = x;
    }
  }

    switch(z){

              case 0: kill();
                        break;
                        
              case 1: Colorfade();
                        break;

              case 2: Fadingblueneon();
                        break;

              case 3: splitpaintmove();
                        break;

               case 4: blinkingstar();
                        break;

              case 5: purpledot();
                        break;

               case 6: beamV2();
                        break;
                        
               case 7: chasing();
                         break;

               case 8: beam();
                         break;
                        
              case 9: whitejump();
                            break;
              
              case 10: redneonmove();   
                            break;
              
              case 11: blueneonmove();
                            break;
              
              case 12: greenmove();
                            break;
              
              case 13: redflash();
                            break;
              
              case 14: blueflash();
                            break;
              
              case 15: redsplitmove();
                            break;
              
              case 16: bluesplitmove();
                            break;
              
              case 17: redyellowsplitmove();
                            break;
              
              case 18: redblueflash();
                            break;
                                    
        }
    
}

void ButtonSwitch(int z)
{
    switch(z){

              case 0: kill();
                        break;
                        
              case 1: Colorfade();
                        break;

              case 2: Fadingblueneon();
                        break;

              case 3: splitpaintmove();
                        break;

               case 4: blinkingstar();
                        break;

              case 5: purpledot();
                        break;

               case 6: beamV2();
                        break;
                        
               case 7: chasing();
                         break;

               case 8: beam();
                         break;
                        
              case 9: whitejump();
                            break;
              
              case 10: redneonmove();   
                            break;
              
              case 11: blueneonmove();
                            break;
              
              case 12: greenmove();
                            break;
              
              case 13: redflash();
                            break;
              
              case 14: blueflash();
                            break;
              
              case 15: redsplitmove();
                            break;
              
              case 16: bluesplitmove();
                            break;
              
              case 17: redyellowsplitmove();
                            break;
              
              case 18: redblueflash();
                            break;
                            
                                    
        }
    
}

//=========================================================================LED SOUND MODES========================================================================================

void LEDSoundResponse_red(int x){
  pixels.clear();
  int limit = x / (1000 / NUMPIXELS);
  B = 0;
  G = 0;
  R = 1;
  for(int i=0;i<=limit;i++){
       if(R>=100){G += 10;}
       pixels.setPixelColor(i, pixels.Color(R, G, B));
       pixels.show();
       R += 8;       
       }
}

void LEDSoundResponse_blue(int x){
  pixels.clear();
  int limit = x / (1000 / NUMPIXELS);
  G = 0;
  B = 1;
  R = 0;
  for(int i=0;i<=limit;i++){
       if(B>=100){R += 10;}
       pixels.setPixelColor(i, pixels.Color(R, G, B));
       pixels.show();
       B += 8;       
       }
}

void LedMidSoundResponse_red(int x){
  pixels.clear();
  int limit = x / (500 / NUMPIXELS);
  G = 0;
  R = 1;
  for(int i=0;i<=limit;i++){
       if(R>=100){G += 10;}
       pixels.setPixelColor((NUMPIXELS/2)+i, pixels.Color(R, G, B));
       pixels.setPixelColor((NUMPIXELS/2)-i, pixels.Color(R, G, B));
       pixels.show();
       R += 16;       
       }
}

void LedMidSoundResponse_blue(int x){
  pixels.clear();
  int limit = x / (500 / NUMPIXELS);
  G = 0;
  B = 1;
  R = 0;
  for(int i=0;i<=limit;i++){
       if(B>=100){R += 10;}
       pixels.setPixelColor((NUMPIXELS/2)+i, pixels.Color(R, G, B));
       pixels.setPixelColor((NUMPIXELS/2)-i, pixels.Color(R, G, B));
       pixels.show();
       B += 16;       
       }
}


void SoundLEDFlash(int x){
  
  if(x<=10){
    R = 0;
    B = 0;
    G = 255;
  }else if(x>10 && x<=75){
    R = 0;
    G = 255;
    B = 255;
  }else if(x>75 && x<=200){
    B = 0;
    R = 255;
    G = 255;
  }else if(x>200 && x<300){
    R = 0;
    G = 0;
    B = 255;
  }else if(x>300 && x<=400){
    G = 0;
    R = 255;
    B = 255;
  }else if(x>400){
    G = 0;
    B = 0;
    R = 255;
  }

  for(int i=0;i<NUMPIXELS;i++){
       pixels.setPixelColor(i, pixels.Color(R, G, B));}
   pixels.show();
}

void SoundRedFade(int x){
  B = 0;
  G = 0;
  if(x<=10){
    R = 5;
  }else if(x>10 && x<=75){
    R = 50;
  }else if(x>75 && x<=200){
    R = 100;
  }else if(x>200 && x<300){
    R = 150;
  }else if(x>300 && x<=400){
    R = 200;
  }else if(x>400){
    R = 255;
  }
   for(int i=0;i<NUMPIXELS;i++){
       pixels.setPixelColor(i, pixels.Color(R, G, B));}
   pixels.show();

}

void Sound_blinkingstar(int x){
  int divident;
      if(x<=10){
        divident = 15;
      }else if(x>10 && x<=75){
        divident = 10;
      }else if(x>75 && x<=200){
        divident = 5;
      }else if(x>200 && x<400){
        divident = 3;
      }else if(x>400 && x<=500){
        divident = 2;
      }else if(x>500){
        divident = 1;
      }
      for(int x=0;x<(NUMPIXELS/divident);x++){
        int i = rand() % NUMPIXELS;
        pixels.setPixelColor(i, pixels.Color(255, 255, 255));
      }
      pixels.show();
      findCode();
    pixels.clear();
  
}


//========================================================================= LED REMOTE MODES ======================================================================================

void kill(){
  buttonshift = 0;
   while(true){
      currentMillis = millis();
      if (currentMillis - previousMillis >= 100) 
      {
        previousMillis = currentMillis;
        for(int i=0;i<30;i++)
        {
          pixels.setPixelColor(i, pixels.Color(0, 0, 0));
        }
        pixels.show();
        findCode();
      }
      
   }

}


void greenmove() // change name
{ 
  buttonshift = 12;
  while(true){      
    int i = 0;
    while(i <= NUMPIXELS - 5)  //while(i <= 25)
    {
      currentMillis = millis();
      if (currentMillis - previousMillis >= interval) {
        previousMillis = currentMillis;        
        pixels.clear(); 
        if(i%2==0){ // shift pixel color as it moves
          pixels.setPixelColor(i, pixels.Color(0, 255, 150));
          pixels.setPixelColor(i+1, pixels.Color(0, 255, 150));
          pixels.setPixelColor(i+2, pixels.Color(0, 255, 150));
          pixels.setPixelColor(i+3, pixels.Color(0, 255, 200));
          pixels.setPixelColor(i+4, pixels.Color(0, 255, 255));
        }else{
          pixels.setPixelColor(i, pixels.Color(255, 50, 0));
          pixels.setPixelColor(i+1, pixels.Color(255, 50, 0));
          pixels.setPixelColor(i+2, pixels.Color(255, 50, 0));
          pixels.setPixelColor(i+3, pixels.Color(255, 50, 0));
          pixels.setPixelColor(i+4, pixels.Color(255, 50, 0));
        }
        pixels.show();   // Send the updated pixel colors to the hardware.
        i++;
        findCode();
      }
    } 
        
   while(true) {
     currentMillis = millis();
     if (currentMillis - previousMillis >= interval) {
        previousMillis = currentMillis; 
          pixels.setPixelColor(NUMPIXELS-5, pixels.Color(0, 255, 150));
          pixels.setPixelColor(NUMPIXELS-4, pixels.Color(0, 255, 150));
          pixels.setPixelColor(NUMPIXELS-3, pixels.Color(0, 255, 150));
          pixels.setPixelColor(NUMPIXELS-2, pixels.Color(0, 255, 200));
          pixels.setPixelColor(NUMPIXELS-1, pixels.Color(0, 255, 255));
      pixels.show();
      break;
     }
   }
   while(true) {      
     currentMillis = millis();
     if (currentMillis - previousMillis >= interval) {
        previousMillis = currentMillis; 
          pixels.setPixelColor(NUMPIXELS-5, pixels.Color(255, 50, 0));
          pixels.setPixelColor(NUMPIXELS-4, pixels.Color(255, 50, 0));
          pixels.setPixelColor(NUMPIXELS-3, pixels.Color(255, 50, 0));
          pixels.setPixelColor(NUMPIXELS-2, pixels.Color(255, 50, 0));
          pixels.setPixelColor(NUMPIXELS-1, pixels.Color(255, 50, 0));
      pixels.show();
      break;
      }
    }
    
   while(true) {
     currentMillis = millis();
     if (currentMillis - previousMillis >= interval) {
        previousMillis = currentMillis;
          pixels.setPixelColor(NUMPIXELS-5, pixels.Color(0, 255, 150));
          pixels.setPixelColor(NUMPIXELS-4, pixels.Color(0, 255, 150));
          pixels.setPixelColor(NUMPIXELS-3, pixels.Color(0, 255, 150));
          pixels.setPixelColor(NUMPIXELS-2, pixels.Color(0, 255, 200));
          pixels.setPixelColor(NUMPIXELS-1, pixels.Color(0, 255, 255));
      pixels.show();    
      break; 
     }
  }


while(i >= 4)
{ // For each pixel..
      currentMillis = millis();
      if (currentMillis - previousMillis >= interval) {
        previousMillis = currentMillis;
      pixels.clear(); // Set all pixel colors to 'off'
     if(i%2==0){
          pixels.setPixelColor(i, pixels.Color(0, 255, 150));
          pixels.setPixelColor(i-1, pixels.Color(0, 255, 150));
          pixels.setPixelColor(i-2, pixels.Color(0, 255, 150));
          pixels.setPixelColor(i-3, pixels.Color(0, 255, 150));
          pixels.setPixelColor(i-4, pixels.Color(0, 255, 150));
        }else{
          pixels.setPixelColor(i, pixels.Color(255, 50, 0));
          pixels.setPixelColor(i-1, pixels.Color(255, 50, 0));
          pixels.setPixelColor(i-2, pixels.Color(255, 50, 0));
          pixels.setPixelColor(i-3, pixels.Color(255, 50, 0));
          pixels.setPixelColor(i-4, pixels.Color(255, 50, 0));
        }
      pixels.show();   // Send the updated pixel colors to the hardware.
      i--;
      findCode();
      }
 }

  while(true) {
    currentMillis = millis();
     if (currentMillis - previousMillis >= interval) {
        previousMillis = currentMillis;
          pixels.setPixelColor(4, pixels.Color(255, 50, 0));
          pixels.setPixelColor(3, pixels.Color(255, 50, 0));
          pixels.setPixelColor(2, pixels.Color(255, 50, 0));
          pixels.setPixelColor(1, pixels.Color(255, 50, 0));
          pixels.setPixelColor(0, pixels.Color(255, 50, 0));
      pixels.show();
      break;
     }
  }

  while(true) {      
      currentMillis = millis();
     if (currentMillis - previousMillis >= interval) {
        previousMillis = currentMillis;
          pixels.setPixelColor(4, pixels.Color(0, 255, 150));
          pixels.setPixelColor(3, pixels.Color(0, 255, 150));
          pixels.setPixelColor(2, pixels.Color(0, 255, 150));
          pixels.setPixelColor(1, pixels.Color(0, 255, 150));
          pixels.setPixelColor(0, pixels.Color(0, 255, 150));
      pixels.show();
      break;
    }
  }

  while(true) {     
      currentMillis = millis();
     if (currentMillis - previousMillis >= interval) {
        previousMillis = currentMillis;
          pixels.setPixelColor(4, pixels.Color(255, 50, 0));
          pixels.setPixelColor(3, pixels.Color(255, 50, 0));
          pixels.setPixelColor(2, pixels.Color(255, 50, 0));
          pixels.setPixelColor(1, pixels.Color(255, 50, 0));
          pixels.setPixelColor(0, pixels.Color(255, 50, 0));
      pixels.show();
      break;
     }
    }

 }
}



void redneonmove() 
{
  buttonshift = 10;
  while(true){
    
    int i = 0;
    while(i <= NUMPIXELS - 4)
    {
      currentMillis = millis();
      if (currentMillis - previousMillis >= interval) {
        previousMillis = currentMillis;
        pixels.clear(); // Set all pixel colors to 'off'
        pixels.setPixelColor(i, pixels.Color(50, 10, 0));
        pixels.setPixelColor(i+1, pixels.Color(100, 25, 0));
        pixels.setPixelColor(i+2, pixels.Color(150, 25, 0));
        pixels.setPixelColor(i+3, pixels.Color(200, 25, 0));
        pixels.setPixelColor(i+4, pixels.Color(255, 25, 0));
        pixels.show();   // Send the updated pixel colors to the hardware.
        i++;
        findCode();
       }
    } 
                    
   previousMillis = 0;              
   while(true) {
    currentMillis = millis();
     if (currentMillis - previousMillis >= interval) {
        previousMillis = currentMillis;                   
                          pixels.setPixelColor(NUMPIXELS-5, pixels.Color(100, 25, 0));
                          pixels.setPixelColor(NUMPIXELS-4, pixels.Color(150, 25, 0));
                          pixels.setPixelColor(NUMPIXELS-3, pixels.Color(200, 25, 0));
                          pixels.setPixelColor(NUMPIXELS-2, pixels.Color(255, 25, 0));
                          pixels.setPixelColor(NUMPIXELS-1, pixels.Color(200, 25, 0));
                          pixels.show();
                          break;
     }
   }
   while(true) {
    currentMillis = millis();
     if (currentMillis - previousMillis >= interval) {
        previousMillis = currentMillis;                       
                          pixels.setPixelColor(NUMPIXELS-5, pixels.Color(150, 25, 0));
                          pixels.setPixelColor(NUMPIXELS-4, pixels.Color(200, 25, 0));
                          pixels.setPixelColor(NUMPIXELS-3, pixels.Color(255, 25, 0));
                          pixels.setPixelColor(NUMPIXELS-2, pixels.Color(200, 25, 0));
                          pixels.setPixelColor(NUMPIXELS-1, pixels.Color(150, 25, 0));
                          break;
     }
   }
     while(true) {
    currentMillis = millis();
     if (currentMillis - previousMillis >= interval) {
        previousMillis = currentMillis;
                          pixels.setPixelColor(NUMPIXELS-5, pixels.Color(200, 25, 0));
                          pixels.setPixelColor(NUMPIXELS-4, pixels.Color(255, 25, 0));
                          pixels.setPixelColor(NUMPIXELS-3, pixels.Color(200, 25, 0));
                          pixels.setPixelColor(NUMPIXELS-2, pixels.Color(150, 25, 0));
...

This file has been truncated, please download it to see its full contents.

Comments

Similar projects you might like

OH HAI! on Windows 10 IoT Core

Project in progress by BuddyC

  • 16,372 views
  • 3 comments
  • 51 respects

Windows 10 IoT Core: UltraSonic Distance Mapper

Project showcase by Anurag S. Vasanwala

  • 65,230 views
  • 23 comments
  • 173 respects

Windows 10 IoT Core : Hydroflyer

Project showcase by Anurag S. Vasanwala

  • 20,349 views
  • 3 comments
  • 59 respects

A PM2.5 and PM 10 Detector design for Windows 10 UWP App

Project tutorial by Jiong Shi

  • 13,146 views
  • 6 comments
  • 24 respects

Home Automation with Arduino MKR1000 and Windows 10

Project tutorial by Ioannis Kydonis

  • 12,884 views
  • 1 comment
  • 38 respects

Home Automation Using Raspberry Pi 2 And Windows 10 IoT

Project tutorial by Anurag S. Vasanwala

  • 356,350 views
  • 102 comments
  • 824 respects
Add projectSign up / Login