コード例 #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
ファイル: 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();
}
コード例 #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
ファイル: 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);
}
コード例 #5
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));

}
コード例 #6
0
void setup()
{
  Serial.begin(115200);
  strip.begin();
  strip.setBrightness(40);
  strip.show();
  cmdMessenger.attach(kSetLED, OnSetLed);
}
コード例 #7
0
 void setup () {
   strip_h.begin();
   strip_d.begin();
   strip_s.begin();
   strip_h.show();
   strip_d.show();
   strip_s.show();
   Serial.begin(57600);
   Wire.begin();
   RTC.begin();
   strip_h.setBrightness(100);
   strip_d.setBrightness(100);
   strip_s.setBrightness(100);
 
   // if (! RTC.isrunning()) {
   // Serial.println("RTC is NOT running!");
   // following line sets the RTC to the date & time this sketch was compiled
   //   RTC.adjust(DateTime(__DATE__, __TIME__));
 }
コード例 #8
0
void colorBeat(uint32_t c, uint8_t wait){
  for(int j=0;j<2;j++){
    for(uint16_t i=0; i<pixels.numPixels();i++){
      pixels.setPixelColor(i,c);
    }
    pixels.show();
    fade();
    delay(wait);
    pixels.setBrightness(200);
  }

}
コード例 #9
0
ファイル: lights.cpp プロジェクト: 0x27/redalert
void runningLights(int del, int brightness){
    pixels.setBrightness(brightness);
    for(int i=0;i<NUMPIXELS;i++){
      pixels.setPixelColor(i, R, G, B);
      if(i!=0){
        pixels.setPixelColor(i-1, 0,0,0);
      }
      pixels.show();
      delay(del);
      pixels.setPixelColor(NUMPIXELS-1, 0,0,0);
    }
}
コード例 #10
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);
}
コード例 #11
0
ファイル: rgb_sketch.cpp プロジェクト: thostr/neopixelstuff
void setup()
{
// Arduino_h is only defined when compiling the sketch in the Arduino IDE.
#ifndef Arduino_h
    // Select line, circle or grid pixel layout for emulator.
    // pixels.setPixelLayout(Strip);
    pixels.setPixelLayout(Ring);
    // pixels.setPixelLayout(Grid);
#endif
    pixels.begin();
    // setBrightness() is intended for use only in setup() and not for animations. It's ignored by the emulator (see
    // the README).
    pixels.setBrightness(50);
    pixels.show();
}
コード例 #12
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();
    }
  }
}
コード例 #13
0
ファイル: neopixel.cpp プロジェクト: 3devangelist/PrusaMendel
void setup_neopixel() {
  SET_OUTPUT(NEOPIXEL_PIN);
  pixels.setBrightness(NEOPIXEL_BRIGHTNESS); // 0 - 255 range
  pixels.begin();
  pixels.show(); // initialize to all off

  #if ENABLED(NEOPIXEL_STARTUP_TEST)
    safe_delay(1000);
    set_neopixel_color(pixels.Color(255, 0, 0, 0));  // red
    safe_delay(1000);
    set_neopixel_color(pixels.Color(0, 255, 0, 0));  // green
    safe_delay(1000);
    set_neopixel_color(pixels.Color(0, 0, 255, 0));  // blue
    safe_delay(1000);
  #endif
  set_neopixel_color(pixels.Color(NEO_WHITE));       // white
}
コード例 #14
0
ファイル: esp8266_fw.c プロジェクト: prashnts/dotfiles
void setup() {
  Serial.begin(115200);
  pixels.begin();
  pixels.setBrightness(BASE_BRIGHTNESS);

  reset_pixels();

  Serial.println();
  Serial.print("Connecting to ");
  Serial.println(ssid);

  WiFi.mode(WIFI_STA);
  WiFi.begin(ssid, password);
  WiFi.hostname(HOSTNAME);

  while (WiFi.status() != WL_CONNECTED) {
    delay(500);
    Serial.print(".");
  }

  Serial.println("WiFi connected");
  Serial.println(WiFi.localIP());

  if (!MDNS.begin(HOSTNAME)) {
    update_pixel(0, 200, 0, 0);
    Serial.println("Error setting up MDNS responder!");
    while (1) {
      delay(1000);
    }
  }
  Serial.println("mDNS responder started");

  update_pixel(0, 0, 200, 0);
  pixels.show();

  server.begin();
  MDNS.addService("http", "tcp", 80);
}
コード例 #15
0
ファイル: ColorWipeEffect.cpp プロジェクト: rootux/sabaled
void ColorWipeEffect::tick(void) {
	// callcounter++;
	// if (callcounter % (*globalSpeedFactor) != 0)
	//  	return;
	 
	Section *sect = &sections[sectionsStart];
	Adafruit_NeoPixel *strip = sect->strip;

	// Fill the dots one after the other with a color
	int tempIndex = currentIndex;
	
	uint32_t tempColorValue = (uint32_t)*SabaleUtils::globalSourceColor;

    strip->setBrightness(tempIndex);
    strip->setPixelColor(tempIndex, tempColorValue);
    strip->show();

	currentIndex++;

	// Touched the end of the strip - go back to the start
	if (tempIndex == strip->numPixels()) {
		currentIndex = 0;
	}
}
コード例 #16
0
void fade(){
  for(int j =0; j<200; j++){
      pixels.setBrightness(200-j);
      delay(20);
  }
}
コード例 #17
0
void setup() {
  strip.setBrightness(BRIGHTNESS);
  strip.begin();
  strip.show(); // Initialize all pixels to 'off'
}
コード例 #18
0
ファイル: sheet.cpp プロジェクト: deldreth/SacredDoorway
void Sheet::init () {
	strip.begin();
	strip.setBrightness(brightness); // Not really necessary, seems that the default of the library is max brightness
	strip.show(); // Initialize all pixels to 'off'
}