how to add sensor with this type of code ?


//this code wanted attach ldr sensor act switch if ldr sensor detected rgb led strip program run if not detected nothing happen ..how add switch or sensor in code ?

//hope can me .. thank you


#include <fastspi_led.h>

#define num_leds 60

// chipsets wire in backwards sort of way
struct crgb { unsigned char b; unsigned char r; unsigned char g; };
// struct crgb { unsigned char r; unsigned char g; unsigned char b; };
struct crgb *leds;

#define pin 11

void setup()
{
  fastspi_led.setleds(num_leds);
  fastspi_led.setchipset(cfastspi_led::spi_lpd6803);
  fastspi_led.setpin(pin);
  fastspi_led.init();
  fastspi_led.start();

  leds = (struct crgb*)fastspi_led.getrgbdata();
}

void loop() {

  for(int j = 0; j < 3; j++) {
    for(int = 0 ; < num_leds; i++ ) {
      memset(leds, 0, num_leds * 3);
      switch(j) {
        case 0: leds.r = 255; break;
        case 1: leds.g = 255; break;
        case 2: leds.b = 255; break;
      }
      fastspi_led.show();
      delay(50);
    }
  }

 
  }
 

well, did try far?

here is tutorial on ldrs. need decide on threshold (ie, @ value choose between light , dark) , put inside if triggers on value, i'd say.

ps.... easier read code if edit post , put code tags round it:

code: [select]
so it
{
looks like
}
this


Arduino Forum > Using Arduino > Programming Questions > how to add sensor with this type of code ?


arduino

Comments

Popular posts from this blog

invalid use of void expresion in FlexiTimer2 library

error: a function-definition is not allowed here before '{' token

LED Strip Code