IR remote led strip

Hello.

How to make WS2812B led strip turn off turn on with IR remote.

Led strip code.

    #include <Adafruit_NeoPixel.h>
    #define PIN     7
    #define NUMPIXELS   169

Adafruit_NeoPixel pixels = Adafruit_NeoPixel(NUMPIXELS, PIN, NEO_RGB + NEO_KHZ800);

void setup() {

  pixels.begin();
 
}

void loop() {
 
  
for (int p = 0; p < NUMPIXELS; p++)
  {
    pixels.setPixelColor(p, pixels.Color(0,0,255));
  }
pixels.show();
  pixels.show();
 
}

I dont know if this code good for turn off on code.

#include <IRremote.h>

const int RECV_PIN = 7;
IRrecv irrecv(RECV_PIN);
decode_results results;
const int redPin = 10;
const int greenPin = 11;


void setup(){
  irrecv.enableIRIn();
  irrecv.blink13(true);
  pinMode(redPin, OUTPUT);
  pinMode(greenPin, OUTPUT);
}

void loop(){
    if (irrecv.decode(&results)){

        switch(results.value){
          case 0xFF38C7: //Keypad button "5"
          digitalWrite(redPin, HIGH);
          delay(2000);
          digitalWrite(redPin, LOW);
          }

        switch(results.value){
          case 0xFF18E7: //Keypad button "2"
          digitalWrite(greenPin, HIGH);
          delay(2000);
          digitalWrite(greenPin, LOW);
          }

        irrecv.resume(); 
    }
}

There have been many many threads talking about this topic on the forum.

Do some searching and reading on what others have been told.

I find alot information but its only use for single led. If codes works and on led strip im good.

Have you read these?

https://www.google.com/search?domains=https%3A%2F%2Fforum.arduino.cc&ei=-Vy3XNS3DdjH-gSfprWAAg&q=ws2812b+ir+remote+site%3Ahttps%3A%2F%2Fforum.arduino.cc&oq=ws2812b+ir+remote+site%3Ahttps%3A%2F%2Fforum.arduino.cc&gs_l=mobile-gws-wiz-serp.3...15057.20109..25218...1.0..0.77.375.5......0....1.ZNnfFiBY118

I dont know if this code good for turn off on code.

You have the Arduino. You have the LED strips. You have the remote. You know what you expect to have happen when you press the S button on the remote.

YOU have the responsibility to determine if the code does what you want.

I can only refer to that:

Have you read these?

ws2812b ir remote site:https://forum.arduino.cc - Google Search

If you read them carefully you might get what you need.

I used to have the same issue as you. I tried it with a single RGB-LED and later converted my code for adafruits Dot Star LEDs.

Here is my Code is used for the single LED. When I am back home I can look up for my code for the dot stars. But you should defineteley try again more forum entries for that topic.

Like PaulS said you are responsible for your code so please don't ask for full codes if you haven't tried out much yet.

//Code from PaulS
#include <IRremote.h>

//Setting the Pins
const byte recvPin = 5; //IR Input
const byte redPin = 11;
const byte greenPin = 10;
const byte bluePin = 9;

unsigned long rgb;
byte r, g, b;
int brightness = 100;

//Defining the Hex-Code for each button.
//Each Button has 2 Hex-Codes since I got 2 different Hex-Codes as I executed another Program to determine the Codes
#define RED               0xFFA25D
#define RED_val2          0xE318261B
#define GREEN             0XFF629D
#define GREEN_val2        0x511DBB
#define BLUE              0xFFE21D
#define BLUE_val2         0xEE886D7F
#define BRIGHT_UP         0xFF18E7
#define BRIGHT_UP_val2    0x3D9AE3F7
#define BRIGHT_DOWN       0xFF4AB5
#define BRIGHT_DOWN_val2  0x1BC0157B
#define OFF               0xFF38C7
#define OFF_val2          0x488F3CBB

#define BRIGHT_SCALE 10



//Initializing the Receiver Pin
IRrecv irrecv(recvPin);
decode_results results; //decoding Decode-Results in variable "results"
unsigned long key_value = 0; //storing code when same button is pressed again



void setup() {
  Serial.begin(9600);
  irrecv.enableIRIn(); //Starting Receiver
  irrecv.blink13(true); //Arduino led blinking when receiving an incoming button-code
  pinMode(redPin, OUTPUT);
  pinMode(greenPin, OUTPUT);
  pinMode(bluePin, OUTPUT);
}

void RGB(unsigned long num) {
  r = num >> 16;
  g = (num >> 8) & 0xFF;
  b = num & 0xFF;

}

void adjust_brightness(int adjust_amount) {
  brightness = constrain(brightness + adjust_amount, 0, 100);
}


void loop() {
  if (irrecv.decode(&results)) {
    if (results.value != 0xFFFFFFFF) {
      //results.value = key_val; //Storing button hex-code if same button is pressed again

      switch (results.value) {
        case RED_val2:
        case RED:             RGB(0x00FF0000); break;
        case GREEN_val2:
        case GREEN:           RGB(0x0000FF00); break;
        case BLUE_val2:
        case BLUE:            RGB(0x000000FF); break;
        case OFF_val2:
        case OFF:             r = g = b = 0; break;
        case BRIGHT_UP_val2:
        case BRIGHT_UP:

          adjust_brightness(BRIGHT_SCALE);
          break;
          
        case BRIGHT_DOWN_val2:
        case BRIGHT_DOWN:

          adjust_brightness(-BRIGHT_SCALE);
          break;
      }

      Serial.print("Code received: "); Serial.println(results.value, HEX);
      Serial.print("Red: "); Serial.println(r);
      Serial.print("Green: "); Serial.println(g);
      Serial.print("Blue: "); Serial.println(b);
      Serial.print("Brightness: "); Serial.println(brightness);
      byte r_adjusted = r * brightness / 100;
      byte g_adjusted = g * brightness / 100;
      byte b_adjusted = b * brightness / 100;
      Serial.print("Adjusted Red: "); Serial.println(r_adjusted);
      Serial.print("Adjusted Green: "); Serial.println(g_adjusted);
      Serial.print("Adjusted Blue: "); Serial.println(b_adjusted);
      analogWrite(redPin, r_adjusted);
      analogWrite(greenPin, g_adjusted);
      analogWrite(bluePin, b_adjusted);
    }

    //key_value = results.value;
    irrecv.resume(); //Clearing button for next incoming button
  }
}