亚洲春色中文字幕久久久-三上亚,一吻二脱三床四吻胸,国产真实伦对白视频全集,在线毛片观看,精品成品入口黄网,国产毛aⅴ片久久久,亚洲AV色香蕉一区二区三区老师,萧皇后A级艳片,色情日本视频更新,99久久亚洲精品日本无码
標題:
用Adafruit_NeoPixel-1.3.4的全彩燈條 Arduino源程序
[打印本頁]
作者:
hai911
時間:
2020-3-10 14:13
標題:
用Adafruit_NeoPixel-1.3.4的全彩燈條 Arduino源程序
經實物實驗60顆全部點亮。多種顯示方式。
Arduino源程序如下:
/*
strip.setPixelColor(uint16_t n, uint8_t r, uint8_t g, uint8_t b);
第一個參數n是彩帶中LED的編號,最接近單片機引腳的編號為0;接下來的三個參數描述像素顏色,分別表示紅色,綠色和藍色的亮度級別,0為最暗,255是最大亮度;
strip.setPixelColor(uint16_t n, uint32_t c);
n是彩帶中LED的編號,顏色color是一種32位類型,將紅色,綠色和藍色值合并為一個數字,有時這樣做能提高程序的效率.通過下面的方法,可以將紅色,綠色和藍色值轉換為32位類型。
uint32_t magenta = strip.Color(red, green, blue);
strip.setBrightness(uint8_t);
一般只在setup()中調用,以保證在整個程序執行過程中LED顏色亮度的一致性,其實在程序中通過合適的邏輯控制各像素的亮度值可能動畫效果更好.
strip.show();
該方法更新彩帶上的全部LED。一個好的習慣是先利用setPixelColor()設置好整個彩帶的顏色,然后再調用show()方法,以防止出現動畫跳躍而不平滑。
*/
#include <Adafruit_NeoPixel.h>
#ifdef __AVR__
#include <avr/power.h>
#endif
//int pinInterrupt = 2; //接中斷信號的腳
//void onChange()
//{
// if ( digitalRead(pinInterrupt) == LOW )
// Serial.println("Key Down");
// else
// Serial.println("Key UP");
//}
/******************************************key
#define BUTTON 3
int val=0;
int old_val=0;
int state=0;
****************************************/
#define PIN 6
// Parameter 1 = number of pixels in strip
// Parameter 2 = Arduino pin number (most are valid)
// Parameter 3 = pixel type flags, add together as needed:參數 3 = 像素類型標志,根據需要添加在一起:
// NEO_KHZ800 800 KHz bitstream (most NeoPixel products w/WS2812 LEDs)
// NEO_KHZ400 400 KHz (classic 'v1' (not v2) FLORA pixels, WS2811 drivers)
// NEO_GRB Pixels are wired for GRB bitstream (most NeoPixel products)
// NEO_RGB Pixels are wired for RGB bitstream (v1 FLORA pixels, not v2)
// NEO_RGBW Pixels are wired for RGBW bitstream (NeoPixel RGBW products)
Adafruit_NeoPixel strip = Adafruit_NeoPixel(60, PIN, NEO_GRB + NEO_KHZ800);
// IMPORTANT: To reduce NeoPixel burnout risk, add 1000 uF capacitor across
// pixel power leads, add 300 - 500 Ohm resistor on first pixel's data input
// and minimize distance between Arduino and first pixel. Avoid connecting
// on a live circuit...if you must, connect GND first.
// This is for Trinket 5V 16MHz, you can remove these three lines if you are not using a Trinket
void setup()
{
#if defined (__AVR_ATtiny85__)
if (F_CPU == 16000000) clock_prescale_set(clock_div_1);
#endif
// End of trinket special code
// Serial.begin(9600); //打開串口
// pinMode( pinInterrupt, INPUT);//設置管腳為輸入
//Enable中斷管腳, 中斷服務程序為onChange(), 監視引腳變化
//attachInterrupt( digitalPinToInterrupt(pinInterrupt), onChange, CHANGE);
// pinMode(BUTTON,INPUT);//key
strip.begin();
strip.show(); // Initialize all pixels to 'off'
}
void loop()
{
/****************************************** key
val = digitalRead(BUTTON);
if((val==HIGH)&&(old_val==LOW))
{
state=1-state;
delay(10);
}
old_val = val;
if(state==1)
{
********************************************/
// Some example procedures showing how to display to the pixels:顯示如何顯示到像素的一些示例過程:
colorWipe(strip.Color(255, 0, 0), 50); // Red delay50
colorWipe(strip.Color(0, 255, 0), 50); // Green
colorWipe(strip.Color(0, 0, 225), 50); // Blue
colorWipe(strip.Color(255, 0, 255), 50); // purple
colorWipe(strip.Color(128, 0, 175), 50); // purple
colorWipe(strip.Color(0, 128, 255), 50);
colorWipe(strip.Color(0, 255, 255), 50);
//colorWipe(strip.Color(0, 0, 0, 255), 50); // White RGBW
// Send a theater pixel chase in...發送劇院像素追逐.
theaterChase(strip.Color(127, 127, 127), 50); // White
theaterChase(strip.Color(255, 0, 0), 50); // Red
theaterChase(strip.Color(0, 0, 255), 50); // Blue劇院追逐
theaterChase(strip.Color(0, 255, 0), 50);
theaterChase(strip.Color(255, 0, 255), 50);
theaterChase(strip.Color(255, 255, 0), 50);
theaterChase(strip.Color(0, 255, 255), 50);
rainbow(20);
rainbowCycle(20);
theaterChaseRainbow(50);
rainbowCycle1(20);
rainbowCycle2(20);
/************************************************** key
}
else
{
colorWipe(strip.Color(0, 255, 0), 50);
}
***************************************************/
}
// 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);
}
}
void rainbow(uint8_t wait)
{
uint16_t i, j;
for(j=0; j<256; j++)
{
for(i=0; i<strip.numPixels(); i++)
{
strip.setPixelColor(i, Wheel((i+j) & 255));
}
strip.show();
delay(wait);
}
}
// Slightly different, this makes the rainbow equally distributed throughout略有不同,這使得彩虹在整個
void rainbowCycle(uint8_t wait)
{
uint16_t i, j;
for(j=0; j<256*5; j++) // 5 cycles of all colors on wheel
{
for(i=0; i< strip.numPixels(); i++)
{
strip.setPixelColor(i, Wheel(((i * 256 / strip.numPixels()) + j) & 255));
}
strip.show();
delay(wait);
}
}
void rainbowCycle1(uint8_t wait)
{
uint16_t i, j;
for(j=256*5; j>=0; j--) // 5 cycles of all colors on wheel
{
for(i=0; i< strip.numPixels(); i++)
{
strip.setPixelColor(i, Wheel(((i * 256 / strip.numPixels()) + j) & 255));
}
strip.show();
delay(wait);
}
}
void rainbowCycle2(uint8_t wait)
{
uint16_t i, j;
for(j=256*5; j>=0; j--) // 5 cycles of all colors on wheel
{
for(i=strip.numPixels(); i>=0; i--)
{
strip.setPixelColor(i, Wheel(((i * 256 / strip.numPixels()) + j) & 255));
}
strip.show();
delay(wait);
}
}
//Theatre-style crawling lights.
void theaterChase(uint32_t c, uint8_t wait)
{
for (int j=0; j<10; j++)
{ //do 10 cycles of chasing
for (int q=0; q < 3; q++)
{
for (uint16_t i=0; i < strip.numPixels(); i=i+3)
{
strip.setPixelColor(i+q, c); //turn every third pixel on
}
strip.show();
delay(wait);
for (uint16_t i=0; i < strip.numPixels(); i=i+3)
{
strip.setPixelColor(i+q, 0); //turn every third pixel off
}
}
}
}
//Theatre-style crawling lights with rainbow effect彩虹色效果的劇院風格爬行燈
void theaterChaseRainbow(uint8_t wait)
{
for (int j=0; j < 256; j++)
{ // cycle all 256 colors in the wheel
for (int q=0; q < 3; q++)
{
for (uint16_t i=0; i < strip.numPixels(); i=i+3)
{
strip.setPixelColor(i+q, Wheel( (i+j) % 255)); //turn every third pixel on
}
strip.show();
delay(wait);
for (uint16_t i=0; i < strip.numPixels(); i=i+3)
{
strip.setPixelColor(i+q, 0); //turn every third pixel off
}
}
}
}
// Input a value 0 to 255 to get a color value.
// The colours are a transition r - g - b - back to r.
uint32_t Wheel(byte WheelPos)
{
WheelPos = 255 - WheelPos;
if(WheelPos < 85)
{
return strip.Color(255 - WheelPos * 3, 0, WheelPos * 3);
}
if(WheelPos < 170)
{
WheelPos -= 85;
return strip.Color(0, WheelPos * 3, 255 - WheelPos * 3);
}
WheelPos -= 170;
return strip.Color(WheelPos * 3, 255 - WheelPos * 3, 0);
}
復制代碼
所有資料51hei提供下載:
sketch_RGB.rar
(2.96 KB, 下載次數: 37)
2020-3-10 14:13 上傳
點擊文件名下載附件
RGB全彩燈
下載積分: 黑幣 -5
作者:
joyist
時間:
2021-12-18 13:42
為什么要回復需要審核,請等待通過
作者:
哮河谷
時間:
2022-2-12 13:11
資源不好用
歡迎光臨 (http://www.denmoz.com/bbs/)
Powered by Discuz! X3.1