2020年8月14日 星期五

單元10_ESP8266_控制WS2812B_彩虹呈現

程式碼

https://gist.github.com/clive520/a402ee10aa5d522ab2de6cbacd4f7f17


 




#include <Adafruit_NeoPixel.h>

#ifdef __AVR__

 #include <avr/power.h> // Required for 16 MHz Adafruit Trinket

#endif


#define LED_PIN    4

#define LED_COUNT 10


Adafruit_NeoPixel strip(LED_COUNT, LED_PIN, NEO_GRB + NEO_KHZ800);



void setup() {


#if defined(__AVR_ATtiny85__) && (F_CPU == 16000000)

  clock_prescale_set(clock_div_1);

#endif


  strip.begin();           // INITIALIZE NeoPixel strip object (REQUIRED)

  strip.show();            // Turn OFF all pixels ASAP

  strip.setBrightness(250 ); // Set BRIGHTNESS to about 1/5 (max = 255)

}



void loop() {

  rainbow(100);             // Flowing rainbow cycle along the whole strip

}


void rainbow(int wait) {

  for(long firstPixelHue = 0; firstPixelHue < 5*65536; firstPixelHue += 256) {

    for(int i=0; i<strip.numPixels(); i++) { // For each pixel in strip...

      int pixelHue = firstPixelHue + (i * 65536L / strip.numPixels());

      strip.setPixelColor(i, strip.gamma32(strip.ColorHSV(pixelHue)));

    }

    strip.show(); // Update strip with new contents

    delay(wait);  // Pause for a moment

  }

}


沒有留言:

張貼留言

AI 網路爬蟲

  AI 網路爬蟲 網路爬蟲(Web Scraping)一直以來都是數據工作者的利器,但它也總是伴隨著令人頭痛的挑戰:你需要懂程式碼、要能解析複雜的 HTML 結構,還要不斷應對網站層出不窮的反爬蟲機制。這道技術門檻,讓許多行銷人員、研究員和創業者望而卻步。 然而,新一代的 AI...