问题 乱闪 电源问题 gpio 系统问题 中断式发送 asrpro
上电初始化 引脚 输出 并 写入0
系统启动后 设置引脚复用 gpio (据说为电源问题,调低亮度可,但usb上还是出现
双循环闪
呼吸灯
计数
int s0[3] = {0,11,10};
int s1[3] = {1,0,11};
int *a[2]= {s0,s1};
// NeoPixel Ring simple sketch (c) 2013 Shae Erisson
// Released under the GPLv3 license to match the rest of the
// Adafruit NeoPixel library
#include <Adafruit_NeoPixel.h>
#include <MsTimer2.h>
#ifdef __AVR__
#include <avr/power.h> // Required for 16 MHz Adafruit Trinket
#endif
// Which pin on the Arduino is connected to the NeoPixels?
#define PIN 6 // On Trinket or Gemma, suggest changing this to 1
// How many NeoPixels are attached to the Arduino?
#define NUMPIXELS 12 // Popular NeoPixel ring size
// When setting up the NeoPixel library, we tell it how many pixels,
// and which pin to use to send signals. Note that for older NeoPixel
// strips you might need to change the third parameter -- see the
// strandtest example for more information on possible values.
Adafruit_NeoPixel pixels(NUMPIXELS, PIN, NEO_GRB + NEO_KHZ800);
#define DELAYVAL 50 // Time (in milliseconds) to pause between pixels
void setup() {
// These lines are specifically to support the Adafruit Trinket 5V 16 MHz.
// Any other board, you can remove this part (but no harm leaving it):
#if defined(__AVR_ATtiny85__) && (F_CPU == 16000000)
clock_prescale_set(clock_div_1);
#endif
// END of Trinket-specific code.
pixels.begin(); // INITIALIZE NeoPixel strip object (REQUIRED)
MsTimer2::set(2000,tim);
MsTimer2::start();
}
int ii = 0;
void tim()
{
ii = ii+1;
}
int s0[3] = {0,11,10};
int s1[3] = {1,0,11};
int *a[2]= {s0,s1};
#define nLeds 12;
void loop()
{
for(int i=0;i<NUMPIXELS/2;i++){
wakeupLed();
//pixels.setBrightness(255/(i+1));
}
for(int i = 1;i<13;i++)
{
breathloop(10*ii,1000*ii);
prograsbar(i);
}
looprun(500);
}
//呼吸灯 等待中。。。
int brightness =0;
void breathloop(uint8_t wait1,int sens)
{
int start = 10;
int tmp = 0;
for (int i = -start; i< start+1;i++)
{
//pixels.clear();
tmp = start-abs(i);
pixels.fill(pixels.Color(0,0,tmp));
//pixels.setBrightness(tmp);
pixels.show();
if(tmp>5)
delay(wait1);
else
delay(20);
}
delay(500);
}
int bn = 0; //唤醒
void wakeupLed()
{
//pixels.setPixelColor(0,pixels.Color(255,255,255));
float fade = 2;
for(int i = NUMPIXELS/2;i>=0;i--)
{
pixels.clear();
int vl = 10;
//pixels.setBrightness(255-bn*10);
pixels.setPixelColor(i-2,pixels.Color(vl,vl,vl));
pixels.setPixelColor(12-i,pixels.Color(vl,vl,vl));
vl = 5;
pixels.setPixelColor(i-1,pixels.Color(vl,vl,vl));
pixels.setPixelColor(11-i,pixels.Color(vl,vl,vl));
vl = 1;
pixels.setPixelColor(i,pixels.Color(vl,vl,vl));
pixels.setPixelColor(10-i,pixels.Color(vl,vl,vl));
pixels.show();
delay(60);
bn = bn +1;
}
}
void loop1()
{
pixels.clear();
pixels.setPixelColor(0,pixels.Color(255,255,255));
float fade = 2;
for(int i = 1;i<NUMPIXELS/2;i++)
{
int vl = 255/(pow(i+1,3));
//pixels.setBrightness(255/(pow(i,2)));
pixels.setPixelColor(i,pixels.Color(vl,vl,vl));
pixels.setPixelColor(12-i,pixels.Color(vl,vl,vl));
pixels.show();
delay(10);
}
}
//int n = 0; //进度灯。。。
void prograsbar(int n)
{
pixels.clear();
for(int i = 0;i<n;i++)
{
pixels.setPixelColor(i,pixels.Color(0,15,0));
pixels.show();
}
delay(200);
n = (n +1)%(NUMPIXELS+1);
}
//循环灯 处理中。。。
void looprun(int wait) {
int rn = 0;
for(int s = 0;s<NUMPIXELS;s++)
{
pixels.clear(); // Set all pixel colors to 'off'
pixels.setBrightness(10);
//strip.set
int nr = 2; //显示点数
for(int r = 0;r<nr;r++)
{
rn = (s+r*NUMPIXELS/nr)%NUMPIXELS;
if(rn > 1)
{
pixels.setPixelColor(rn,pixels.Color(0, 255, 0));
pixels.setPixelColor(rn-1,pixels.Color(0, 155, 0));
pixels.setPixelColor(rn-2,pixels.Color(0, 55, 0));
}
else
{ int result = 0;
pixels.setPixelColor(rn,pixels.Color(0, 255, 0));
result = rn -1; //0 0-1 -1 1
if(result < 0 ) // -1 < 0 0
pixels.setPixelColor(12+result,pixels.Color(0, 155, 0)); //11
else
pixels.setPixelColor(rn-1,pixels.Color(0, 155, 0));
result = rn -2; //0-2 -2 -1
if(result<0)
pixels.setPixelColor(12+result,pixels.Color(0, 55, 0)); //10
else
pixels.setPixelColor(rn-2,pixels.Color(0, 55, 0));
}
}//round end
pixels.show();
delay(wait);
}
}