コード例 #1
0
ファイル: lights.cpp プロジェクト: 0x27/redalert
void glow(int del, int bri){
  int cb = 0;
  int d = del/(100 * bri/100);
  if(d < 1){
    d=1;
  }
  
  for(int i=0;i<NUMPIXELS;i++){
    pixels.setPixelColor(i, R,G,B);
  }
  
  while(cb<bri){
    cb++;
    pixels.setBrightness(cb);
    pixels.show();
    delay(d);
  }
  
  while(cb>1){
    cb--;
    pixels.setBrightness(cb);
    pixels.show();
    delay(d);
  }
}
コード例 #2
0
ファイル: rgb_sketch.cpp プロジェクト: thostr/neopixelstuff
void xmasRedGreenTwinkles(u16 runSec)
{
    const u8 flashOnDelayMs = 20;
    const u8 flashPauseMs = 150;
    const u8 numTwinklesPerSwap = 3;
    bool redOrGreenFirst = false;
    u32 startMs = millis();
    u8 numTwinklesToNextSwap = 0;
    while (millis() < startMs + runSec * 1000UL) {
        if (!numTwinklesToNextSwap--) {
            numTwinklesToNextSwap = numTwinklesPerSwap;
            redOrGreenFirst = !redOrGreenFirst;
        }
        u8 twinkleLedIdx = random(0, pixels.numPixels() - 1);
        pixels.setPixelColor(twinkleLedIdx, 0xffffff);
        pixels.show();
        delay(flashOnDelayMs);
        for (u8 i = 0; i < pixels.numPixels(); ++i) {
            u32 c = (i + redOrGreenFirst) & 1 ? 0xff0000 : 0x00ff00;
            pixels.setPixelColor(i, c);
        }
        pixels.show();
        delay(flashPauseMs);
    }
}
コード例 #3
0
ファイル: lights.cpp プロジェクト: 0x27/redalert
void disco(int del, int brightness){
  pixels.setBrightness(brightness);
  
  for(int i=0;i<NUMPIXELS;i++){
    int ran = random(0,2);
    if(ran == 0){
        int r = random(0,256);
        int g = random(0,256);
        int b = random(0,256);
        pixels.setPixelColor(i,r,g,b);
    }
  }
  pixels.show();
  delay(del * random(1,4));
  for(int i=0;i<NUMPIXELS;i++){
    int ran = random(0,4);
    if(ran !=0){
        int r = random(0,256);
        int g = random(0,256);
        int b = random(0,256);
        pixels.setPixelColor(i,0,0,0);
    }
  }
  pixels.show();
  delay(del * random(1,3));
}
コード例 #4
0
 void loop () {
 
   DateTime now = RTC.now();
 //this is running a test cycle that lights up both parts for a few minutes every hour.
 //to change it to birthdays just add now.day and now.month conditions like below
   if (now.minute() >= 11 && (now.minute() <= 13)){
     rainbowCycle_A(20);
   }
   
   else if (now.minute() >= 22 && (now.minute() <= 25)){
     rainbowCycle_B(20);
   }
 
    else{
    
    for(q=0; q< 13; q++) {
    
    strip_h.setPixelColor(q,0,0,0);
    strip_d.setPixelColor(q,0,0,0);
    strip_s.setPixelColor(q,0,0,0);
     
     strip_h.show();
      strip_d.show();
       strip_s.show();
   
   }
 
 }
 
   }
コード例 #5
0
ファイル: lights.cpp プロジェクト: 0x27/redalert
void police(int del, int bri){
  pixels.setBrightness(bri);
  int delFac = 6;
  
  for(int k=0; k<6; k++){
    if(k==3){
      delay(del*delFac);
    }
    if(k<3){
      for(int i=0;i<NUMPIXELS/2;i++){
        pixels.setPixelColor(i, 255,0,0);
      }
    }
    else{
      for(int i=NUMPIXELS/2;i<NUMPIXELS;i++){
        pixels.setPixelColor(i, 0,0,255);
      }
    }
  
    pixels.show();
    delay(del);
    
    for(int i=0;i<NUMPIXELS;i++){
      pixels.setPixelColor(i, 0,0,0);

    }
    
    pixels.show();
    delay(del/2);
  }
  
  delay(del * delFac);
}
コード例 #6
0
void set_all_leds(unsigned long int color){
	for(byte i=0;i<MAGIC_LEDS;i++){
		top_panels.setPixelColor(i, color );
	}
	bottom_panels.setPixelColor(0, color );
	bottom_panels.setPixelColor(1, color );	
	top_panels.show();
	bottom_panels.show();
}
コード例 #7
0
void rainbowFade2White(uint8_t wait, int rainbowLoops, int whiteLoops) {
  float fadeMax = 100.0;
  int fadeVal = 0;
  uint32_t wheelVal;
  int redVal, greenVal, blueVal;

  for(int k = 0 ; k < rainbowLoops ; k ++) {
    for(int j=0; j<256; j++) { // 5 cycles of all colors on wheel
      for(int i=0; i< strip.numPixels(); i++) {
        wheelVal = Wheel(((i * 256 / strip.numPixels()) + j) & 255);

        redVal = red(wheelVal) * float(fadeVal/fadeMax);
        greenVal = green(wheelVal) * float(fadeVal/fadeMax);
        blueVal = blue(wheelVal) * float(fadeVal/fadeMax);

        strip.setPixelColor( i, strip.Color( redVal, greenVal, blueVal ) );
      }

      // First loop, fade in!
      if(k == 0 && fadeVal < fadeMax-1) {
        fadeVal++;
      }
      // Last loop, fade out!
      else if(k == rainbowLoops - 1 && j > 255 - fadeMax ) {
        fadeVal--;
      }

      strip.show();
      delay(wait);
    }
  }

  delay(500);

  for(int k = 0 ; k < whiteLoops ; k ++) {
    for(int j = 0; j < 256 ; j++) {
      for(uint16_t i=0; i < strip.numPixels(); i++) {
        strip.setPixelColor(i, strip.Color(0,0,0, gamma[j] ) );
      }
      strip.show();
    }

    delay(2000);
    for(int j = 255; j >= 0 ; j--) {
      for(uint16_t i=0; i < strip.numPixels(); i++) {
        strip.setPixelColor(i, strip.Color(0,0,0, gamma[j] ) );
      }
      strip.show();
    }
  }

  delay(500);
}
コード例 #8
0
ファイル: lights.cpp プロジェクト: 0x27/redalert
void flashingLights(int del, int brightness){
  pixels.setBrightness(brightness);
  for(int i=0;i<NUMPIXELS;i++){
    pixels.setPixelColor(i, R,G,B);
  }
  
  pixels.show();
  delay(del);
  for(int i=0;i<NUMPIXELS;i++){
    pixels.setPixelColor(i, 0,0,0);
  }
  
  pixels.show();
  delay(del);
}
コード例 #9
0
ファイル: LearnBitsShield.cpp プロジェクト: LearnBits/Shield
// Shield initialize function:
void Init_LearnBitsShield(){
  // initialize serial ports:
  Serial.begin(57600); // Pc Communication
  Serial1.begin(57600); // Pi communication
  Serial2.begin(57600); // Bluetooth Communication

  // initialize motor driver
  pinMode(MOT_STBY, OUTPUT);
  pinMode(MOT_PWMA, OUTPUT);
  pinMode(MOT_AIN1, OUTPUT);
  pinMode(MOT_AIN2, OUTPUT);
  pinMode(MOT_PWMB, OUTPUT);
  pinMode(MOT_BIN1, OUTPUT);
  pinMode(MOT_BIN2, OUTPUT);
  digitalWrite(MOT_STBY, LOW);  //Set standby

  // initialize Neo pixels
  pixels.begin(); // initializes NeoPixel library.
  for(int ii=0;ii<NUMPIXELS;ii++){
    pixels.setPixelColor(ii, pixels.Color(0,0,0)); // Set pixel color. 
  }
  pixels.show(); // Updated pixel color Hardware.
  

}// end Init_LearnBitsShield
コード例 #10
0
ファイル: application.cpp プロジェクト: blinkingnoise/Sming
void TheaterChase() {
   int i,b=0;
   if (ChaseCycle > 0)
   {
  
	       if (TheaterChaseQ == 0) b=3;
	       if (TheaterChaseQ == 1) b=0;
	       if (TheaterChaseQ == 2) b=1;
	       if (TheaterChaseQ == 3) b=2;
	       
	   	   for (i=0; i < strip.numPixels(); i=i+4)
             strip.setPixelColor(i+b, 0);        //turn prev every third pixel off
	   	   
	   	   	for (i=0; i < strip.numPixels(); i=i+4)
               strip.setPixelColor(i+TheaterChaseQ, StripColor);    //turn every third pixel on
	   	   	
	   	   	strip.show();
	   	   	TheaterChaseQ++;
	   	   	if (TheaterChaseQ > 3)
	   	   	{
	   	   		TheaterChaseQ=0;
	   	   		ChaseCycle--;
	   	   	}
   }
   else
   {
	   // finish this demo
		StripDemoType++;         // next demo type
		TheaterChaseTimer.stop();   // stop this demo dimer
		StripDemoTimer.initializeMs(2000, StartDemo).start(true);  // start another demo after 2 seconds
   }	   
} 
コード例 #11
0
ファイル: sheet.cpp プロジェクト: deldreth/SacredDoorway
void Sheet::fade3xTo (int sh1, uint16_t sr1, uint16_t sg1, uint16_t sb1, uint16_t er1, uint16_t eg1, uint16_t eb1,
					  int sh2, uint16_t sr2, uint16_t sg2, uint16_t sb2, uint16_t er2, uint16_t eg2, uint16_t eb2,
					  int sh3, uint16_t sr3, uint16_t sg3, uint16_t sb3, uint16_t er3, uint16_t eg3, uint16_t eb3) {
	int steps = 256;
	
	for (int i = 0; i < steps; i++) {
		SetColor(	
			sh1, 
			sr1 + i * (er1 - sr1) / steps,
			sg1 + i * (eg1 - sg1) / steps,
			sb1 + i * (eb1 - sb1) / steps,
			false
		);

		SetColor(	
			sh2, 
			sr2 + i * (er2 - sr2) / steps,
			sg2 + i * (eg2 - sg2) / steps,
			sb2 + i * (eb2 - sb2) / steps,
			false
		);

		SetColor(	
			sh3, 
			sr3 + i * (er3 - sr3) / steps,
			sg3 + i * (eg3 - sg3) / steps,
			sb3 + i * (eb3 - sb3) / steps,
			false
		);

		strip.show();
	}
}
コード例 #12
0
ファイル: sheet.cpp プロジェクト: deldreth/SacredDoorway
void Sheet::Chakras() {
	uint32_t chakras[] = {
		strip.Color(255, 255, 255), // white
		strip.Color(230, 0, 255),   // purple
		strip.Color(34, 0, 255),    // blue
		strip.Color(0, 255, 34),    // green
		strip.Color(255, 247, 0),   // yellow
		strip.Color(255, 111, 0),   // orange
		strip.Color(255, 0, 0)      // red
	};
	
	uint16_t cur = 6;
	int i;
	
	for(i = 29; i >= 0; i--) {
		if (i == 26 || i == 22 || i == 18 || i == 14 || i == 10 || i == 6) {
			cur--;
		}
		
		strip.setPixelColor(i, chakras[cur]);
		strip.setPixelColor(420 - i, chakras[cur]);
		
		strip.show();
		
		delay(20);
		
		strip.setPixelColor(i, 0);
		strip.setPixelColor(420 - i, 0);
	}
}
コード例 #13
0
ファイル: sheet.cpp プロジェクト: deldreth/SacredDoorway
void Sheet::BlackSpiral (uint8_t wait) {
	uint16_t i;
	for (i = 0; i < 30; i++) {
		strip.setPixelColor(i, 0);
		strip.setPixelColor(390 + i, 0);
		
		strip.setPixelColor(210 - i, 0);
		strip.setPixelColor(211 + i, 0);
		
		strip.setPixelColor(59 - i, 0);
		strip.setPixelColor(361 + i, 0);
		
		strip.setPixelColor(89 - i, 0);
		strip.setPixelColor(331 + i, 0);
		
		strip.setPixelColor(119 - i, 0);
		strip.setPixelColor(301 + i, 0);
		
		strip.setPixelColor(149 - i, 0);
		strip.setPixelColor(271 + i, 0);
		
		strip.setPixelColor(180 - i, 0);
		strip.setPixelColor(241 + i, 0);
		
		strip.show();
		delay(wait);
	}
}
コード例 #14
0
ファイル: Trail.cpp プロジェクト: ilans/Swish
bool Trail::move(){
  int cur_mil = millis();
  if (start_mil==0) {start_mil = cur_mil;}
  int delta_pix = float(cur_mil-start_mil)*leds_per_mil;
  if(prv_delta_pix != delta_pix) {
    prv_delta_pix = delta_pix;
    int head_pix = origin + delta_pix;
    if(!direction) head_pix = origin - delta_pix;
    if(head_pix<0) head_pix += strip_len;
    if(head_pix>strip_len-1) head_pix -= strip_len;
    for(int j=0; j<=length; j++) {
      int p = head_pix-j;
      if(!direction){
        p = head_pix+j;
      }
      if(p<0) p += strip_len;
      if(p>strip_len-1) p -= strip_len;
      if( ( o2t_dir &&  direction) && (p>=origin && p<=target) ||
          ( o2t_dir && !direction) && (p<=origin || p>=target) ||
          (!o2t_dir && !direction) && (p<=origin && p>=target) ||
          (!o2t_dir &&  direction) && (p>=origin || p<=target) )
      {
        strip.setPixelColor(p, strip.Color(r-j*r_fade, g-j*g_fade, b-j*b_fade));
      }
    }
    strip.show();
  }
  if (delta_pix - length >= o2t_delta) return true;
  return false;
}
コード例 #15
0
ファイル: rgb_sketch.cpp プロジェクト: thostr/neopixelstuff
void smoothRunners(u16 runSec, u16 delayMs, struct Segment* segmentPtrIn, u8 numSegments)
{
    u16 superPosBuf[numSegments];
    u16 numSuperPositions = pixels.numPixels() << 8;
    u16 superPosOffset = numSuperPositions / numSegments;
    for (u8 i = 0; i < numSegments; ++i) {
        superPosBuf[i] = i * superPosOffset;
    }

    u32 startMs = millis();
    while (millis() < startMs + runSec * 1000UL) {
        clear(0, 0);
        Segment* segmentPtr = segmentPtrIn;
        for (u8 i = 0; i < numSegments; ++i) {
            u16 superPos = superPosBuf[i];
            superPos = wrapAdd(superPos, segmentPtr->speed, numSuperPositions);
            superPosBuf[i] = superPos;
            u8 numSegmentPixels = segmentPtr->lengthPercent * pixels.numPixels() / 100;
            if (numSegmentPixels < 2) {
                numSegmentPixels = 2;
            }
            drawTaperedSegment(superPos, numSegmentPixels, segmentPtr->color);
            ++segmentPtr;
        }
        pixels.show();
        delay(delayMs);
    }
}
コード例 #16
0
ファイル: pixels.cpp プロジェクト: RockTheBike/lighting_test
// Fill the dots one after the other with a color
void setStrip(Adafruit_NeoPixel s, uint8_t r, uint8_t g, uint8_t b) {
	for (uint16_t i = 0; i < s.numPixels(); i++) {
		s.setPixelColor(i, r, g, b);
		//delay(wait);
	}
	s.show();
}
コード例 #17
0
ファイル: lights.cpp プロジェクト: 0x27/redalert
void still(int brightness){
  pixels.setBrightness(brightness);
    for(int i=0;i<NUMPIXELS;i++){
    pixels.setPixelColor(i, R,G,B);
  }
  pixels.show();
}
コード例 #18
0
ファイル: neopixel.c プロジェクト: ismailuddin/arduino
void setup() {
  // put your setup code here, to run once:
  strip.begin();
  strip.show();
  pinMode(switchPin, INPUT);

}
コード例 #19
0
ファイル: arduino.cpp プロジェクト: takustaqu/bakkathon
//NEOPIXEL LIBRARRY
// Fill the dots one after the other with a color
void colorWipe(uint32_t c, uint8_t wait) {
  for(uint16_t i=0; i<strip.numPixels(); i++) {
      strip.setPixelColor(i, c);
      strip.show();
      delay(wait);
  }
}
コード例 #20
0
ファイル: arduino.cpp プロジェクト: takustaqu/bakkathon
void setup() {
  Serial.begin(9600);
  while (!Serial) {
    ;
  }
  MCUSR = 0;  // for Reset : clear out any flags of prior resets.

/*
  if(!isDebug){//TODO Servo bug fix....
    // Initialize SD card.
    Serial.print(F("\nInitializing SD card..."));
    if (card.init(SPI_HALF_SPEED, chipSelectPin)) {
      //Serial.print(F("OK"));
    } else {
      //Serial.print(F("NG"));
      abort();
    }
    memset(buffer, 0, 0x200);
  }
  */


  //For Neopixel
  strip.begin();
  strip.show(); // Initialize all pixels to 'off'

  sv.attach(SERVO_PIN, 800, 2300);// For Servo

  pinMode(buttonPin, INPUT);// for BUtton
}
コード例 #21
0
void setBallLight(uint32_t color)
{
    uint8_t i;

    for(i = 0; i < PIXEL_COUNT; i++) {
        if (i % LED_MODULO == 0) {
            strip1.setPixelColor(i, color);
            strip2.setPixelColor(i, color);
        } else {
            strip1.setPixelColor(i, 0);
            strip2.setPixelColor(i, 0);
        }
    }
    strip1.show();
    strip2.show();
}
コード例 #22
0
void setup() {
    pinMode(PIN_DIAGNOSTIC_LED, OUTPUT);

    Serial.begin(9600);

    debug(F("initializing LED Strip\n"));
    strip.begin();
    strip.setBrightness(0xff);

    strip.show();

    Color sunset(0x80, 0x20, 0x20),
            morning(0xa0, 0x5e, 0x50),
            noon(0xff, 0xff, 0xff),
            afternoon(0xa0, 0x5e, 0x50),
            night(0x10, 0x15, 0x20);

    // switch on at 6 (use an external timer for that)
    fade(Color::OFF, sunset, minutes_to_ms(45));

    fade(sunset, morning, minutes_to_ms(30));

    fade(morning, noon, minutes_to_ms(45 + 4 * 60));

    fade(noon, noon, minutes_to_ms(4 * 60));

    fade(noon, afternoon, minutes_to_ms(2 * 60));

    fade(afternoon, sunset, minutes_to_ms(45));

    fade(sunset, night, minutes_to_ms( 30));

    fade(night, Color::OFF, minutes_to_ms(30));

}
コード例 #23
0
void pulseWhite(uint8_t wait) {
  for(int j = 0; j < 256 ; j++) {
    for(uint16_t i=0; i<strip.numPixels(); i++) {
      strip.setPixelColor(i, strip.Color(0,0,0, gamma[j] ) );
    }
    delay(wait);
    strip.show();
  }

  for(int j = 255; j >= 0 ; j--){
    for(uint16_t i=0; i<strip.numPixels(); i++) {
      strip.setPixelColor(i, strip.Color(0,0,0, gamma[j] ) );
    }
    delay(wait);
    strip.show();
  }
}
コード例 #24
0
ファイル: neopixel.c プロジェクト: ismailuddin/arduino
void loop() {
  // put your main code here, to run repeatedly:
  reading = analogRead(potPin);
  val = (reading/1024.0) * 13;
  colorVal = (reading/1024.0) * 255;
  
  if (digitalRead(switchPin) == HIGH && lastButton == LOW)
  {
    delay(250); // Account for contact debounce
    NeopixelColor = !NeopixelColor;
    
  }
  
  if (NeopixelColor == false)
  {
    // Neopixel LED number code
    strip.setBrightness(40);
    if (val != prevVal)
    {
      for ( x = 0; x < val; x++) 
      {
        strip.setPixelColor(x,255,0,255);
      }
      for (x=val; x<13; x++) 
      { 
        strip.setPixelColor(x,0,0,0);
        strip.show();
      }
      prevVal = val;
    }
    else
    {
      strip.show();
    }
    
  }
  else
  {
    // Neopixel Color code
    for (x=0; x < prevVal; x++)
    {
      strip.setPixelColor(x,colorVal,0,255-colorVal);
      strip.show();
    }
  }
}
コード例 #25
0
void stripSet(uint32_t c, uint8_t wait) {
	for(uint16_t i=0; i<strip.numPixels(); i++) {
		strip.setPixelColor(i, c);
	}
	// move the show outside the loop
	strip.show();
	delay(wait);
}
コード例 #26
0
void setup()
{
  Serial.begin(115200);
  strip.begin();
  strip.setBrightness(40);
  strip.show();
  cmdMessenger.attach(kSetLED, OnSetLed);
}
コード例 #27
0
ファイル: sheet.cpp プロジェクト: deldreth/SacredDoorway
void Sheet::spiralTo(int sh, uint16_t r, uint16_t g, uint16_t b) {
	for (int i = sheets[sh - 1]; i < sheets[sh]; i++) {
		strip.setPixelColor(i, r, g, b);
		int offset = 419 - 30;
		strip.setPixelColor(offset + i, r, g, b);
		strip.show();
		delay(20);
	}
}
コード例 #28
0
 void rainbowCycle_B(uint8_t wait) {
   uint16_t i, j;
 
   for(j=0; j<256*1; j++) { 
     for(i=0; i< 13; i++) {
   
       strip_h.setPixelColor(i, Wheel(((i * 50 / 13) + j) & 255));
       delayMicroseconds(550);
     }
     for(k=0; k< 4; k++) {
       strip_d.setPixelColor(k, Wheel(((k * 50 / 4) + j) & 255));
       delayMicroseconds(550);
     }
     strip_d.show();
     strip_h.show();
    //   delay(wait);
   }
 }
コード例 #29
0
void strobe(uint32_t c, int wait) {
	for (int i = 0; i < PIXEL_COUNT; i++) {
		strip.setPixelColor(i, c);
	}
	strip.show();
	delay(wait);
	stripSet(OFF,0);
	delay(wait);  	
}
コード例 #30
0
// Set all pixels in the strip to a solid color, then wait (ms)
void colorAll(uint32_t c, uint8_t wait) {
  uint16_t i;
  
  for(i=0; i<strip.numPixels(); i++) {
    strip.setPixelColor(i, c);
  }
  strip.show();
  delay(wait);
}