
No License
PlainText
2019年11月18日
#include <Adafruit_NeoPixel.h>
#define BUTTON_PIN 2
#define PIXEL_PIN 0 //セッションベースに仕込んだGRB LED接続ピン
#define PIXEL_COUNT 12 //LEDの数=12個
Adafruit_NeoPixel strip = Adafruit_NeoPixel(PIXEL_COUNT, PIXEL_PIN, NEO_GRB + NEO_KHZ800); //NeoPoxelの諸処理
bool oldState = HIGH; //直前のボタン状態保持
int showType = 0; //ボタン押下回数カウンタ
int x = 0;
void setup() {
pinMode(BUTTON_PIN, INPUT_PULLUP);
strip.begin(); //必須
strip.show(); // Initialize all pixels to 'off'
//↓↓↓起動後の(割とどうでもいい)演出↓↓↓
colorWipe(strip.Color(0, 0, 255), 0);//青
for(int i=0;i<3;i++){
colorWipe(strip.Color(0, 0, 0), 50);//黒(off)でワイプ
delay(500);
colorWipe(strip.Color(32, 64, 0), 50);//赤橙でワイプ
delay(500);
}
colorWipe(strip.Color(0, 0, 0), 50);//黒(off)でワイプ
delay(500);
colorWipe(strip.Color(3, 2, 5), 0);//弱い白でワイプ
}
void loop() {
bool newState = digitalRead(BUTTON_PIN); //ボタン状態の取得
if (newState == LOW && oldState == HIGH) {//ボタン押下によるHighからLowへの変化検知
delay(20); //押して離す僅かな間の時間稼ぎ
newState = digitalRead(BUTTON_PIN); //delayを経てなおLowなら「押された」とみなす
if (newState == LOW) {
showType++; //「押された」ならshowType変数を増やす
}
if (showType == 1){
for(int i =0;i<5;i++){rainbowCycle(0);}
for(int i =0;i<1;i){
rainbow(50);
if(digitalRead(BUTTON_PIN) == LOW){
showType++;i++;
colorWipe(strip.Color(127, 0, 0), 0);//緑でワイプ
colorWipe(strip.Color(1, 1, 1), 50);
continue;
}
}
}
if (showType >= 2){
showType=0; //showType変数が一定値以上なら0にリセット
}
}
// Set the last button state to the old state.
oldState = newState;
}
//LED点灯スイッチ関数================================================================
//switchで制御しているためパターン毎にループがなされない問題あり
void startShow(int i) {
switch(i){
case 0: colorWipe(strip.Color(255, 255, 255), 50); // White
break;
case 1: colorWipe(strip.Color(255, 0, 0), 50); // Green
break;
case 2: colorWipe(strip.Color(0, 255, 0), 50); // Red
break;
case 3: colorWipe(strip.Color(0, 0, 255), 50); // Blue
break;
case 4: theaterChase(strip.Color(127, 127, 127), 50); // White
break;
case 5: theaterChase(strip.Color(127, 0, 0), 50); // Green
break;
case 6: theaterChase(strip.Color( 0, 127, 0), 50); // Red
break;
case 7: theaterChase(strip.Color( 0, 0, 127), 50); // Blue
//rainbow(20);
break;
case 8: colorWipe(strip.Color( 0, 0, 0), 50);
//rainbowCycle(5);
break;
case 9: theaterChaseRainbow(1);
break;
}
}
//LED点灯パターン関数郡==================================================================================
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);
}
}
void rainbowCycle(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 * 256 / strip.numPixels()) + j) & 255));
}
strip.show();
delay(wait);
}
}
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 (int i=0; i < strip.numPixels(); i=i+3) {
strip.setPixelColor(i+q, c); //turn every third pixel on
}
strip.show();
delay(wait);
for (int i=0; i < strip.numPixels(); i=i+3) {
strip.setPixelColor(i+q, 0); //turn every third pixel off
}
}
}
}
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 (int 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 (int i=0; i < strip.numPixels(); i=i+3) {
strip.setPixelColor(i+q, 0); //turn every third pixel off
}
}
}
}
uint32_t Wheel(byte WheelPos) { //rainbow関数で使用
WheelPos = 255 - WheelPos;
if(WheelPos < 85) {
return strip.Color(255 - WheelPos * 3, 0, WheelPos * 3);
} else if(WheelPos < 170) {
WheelPos -= 85;
return strip.Color(0, WheelPos * 3, 255 - WheelPos * 3);
} else {
WheelPos -= 170;
return strip.Color(WheelPos * 3, 255 - WheelPos * 3, 0);
}
}
Adruino IDE経由でDigiSparkに転送、PL9823-F5を12個連ね組み込んだプラモデル台座(参考:https://hobby-snap.com/posts/4963)を駆動させるプログラム

Anonymous
2021年04月19日
Medicines information. Long-Term Effects.
<a href="https://topregabalin.top">i can lyrica</a> in US
Some information about medicament. Get information here.

Anonymous
2021年04月27日
Drugs prescribing information. Effects of Drug Abuse.
<a href="https://topregabalin.top">how can i get generic lyrica without dr prescription</a> in US
Some trends of pills. Read information here.

Anonymous
2021年04月30日
female cialis <a href="https://mycialistabs.com/">difference between viagra and cialis</a> how often can you take cialis

Anonymous
2021年04月30日
buy cialis online usa <a href="https://mycialistabs.com/">cialis manufacturer coupon lilly</a> generic cialis price

Anonymous
2021年05月02日
how much is cialis <a href="https://toptadalafiltabs.com/">what is the difference between viagra and cialis</a> cialis vs. viagra

Anonymous
2021年05月03日
can women take cialis <a href="https://toptadalafiltabs.com/">what is tadalafil used for</a> cialis back pain

Anonymous
2021年05月04日
how to write a biography essay <a href="https://topessaywriterfas.com/">web site</a> how to write a perfect sat essay

Anonymous
2021年05月05日
how to write a 4 page essay in one night <a href="https://topessaywriterfas.com/">good ways to start a college essay</a> how to write a structural analysis essay

Anonymous
2021年05月06日
community service at school essay <a href="http://writemyessayslfd.com/">writing descriptive essay</a> help to write an essay

Anonymous
2021年05月07日
los angeles community service essay <a href="http://writemyessayslfd.com/">http://www.writemyessayslfd.com/</a> essay writing student and social service

Anonymous
2021年05月07日
sildenafil teva <a href="https://mrviagrashop.com">viagra sex</a> snorting viagra

Anonymous
2021年05月07日
generic viagra names <a href="https://mrviagrashop.com">sildenafil citrate tablets 100mg</a> sildenafil walmart

Anonymous
2021年05月07日
teva generic viagra <a href="https://mysildenafilkr.com/">sildenafil 40 mg</a> viagra over the counter usa

Anonymous
2021年05月08日
over the counter viagra <a href="https://mysildenafilkr.com/">best natural viagra</a> over the counter viagra substitute walgreens

Anonymous
2021年05月11日
cialis amazon <a href="http://tadalafilled.com/">cialis directions</a> cialis generics

Anonymous
2021年05月11日
film resume <a href="http://coverletterforresumetop.com/">perfect cover letter</a> monster resume

Anonymous
2021年05月12日
making a cover letter <a href="http://coverletterforresumetop.com/">write my resume</a> writing a cover letter for a job

Anonymous
2021年05月12日
canadian pharmacy online cialis <a href="http://tadalafilled.com/">liquid cialis</a> purchase cialis online

Anonymous
2021年05月12日
accounts payable resume <a href="https://writingacoverletteronline.com/">professional cv writing service</a> linkedin resume upload

Anonymous
2021年05月13日
cover letter to whom it may concern <a href="https://writingacoverletteronline.com/">entry level resume writing</a> help desk resume

Anonymous
2021年05月13日
sildenafil for women <a href="https://edviagramaster.net/">women viagra</a> canadian pharmacy viagra 50 mg

Anonymous
2021年05月14日
viagra without a doctor prescription canada <a href="https://edviagramaster.net/">cost of viagra</a> sildenafil online usa

Anonymous
2021年05月15日
viagra from canada <a href="https://sildenafilviagratop.com">sildenafil over the counter</a> natural viagra for men

Anonymous
2021年05月15日
cialis free 30 day trial <a href="https://cialisortadalafil.com/">cialis precio</a> cialis 20 mg price

Anonymous
2021年05月16日
black cialis <a href="https://cialisortadalafil.com/">cialis from india</a> coupons for cialis

Anonymous
2021年05月16日
itsoktocry viagra <a href="https://sildenafilviagratop.com">viagra from india</a> viagra jokes

Anonymous
2022年03月28日
essay about civil service <a href="https://englishessayblog.com/">do my essay cheap</a> what to write for a community service essay

Anonymous
2021年05月16日
cialis definition <a href="https://topcialistabs.com/">how to take cialis 20mg</a> when will generic cialis be available in the us

Anonymous
2021年05月17日
cialis free sample <a href="https://topcialistabs.com/">cialis prescription</a> bph cialis

Anonymous
2021年05月18日
Medicine information sheet. Effects of Drug Abuse.
<a href="https://paxil4u.top">can i purchase cheap paxil</a> in US
All about medicament. Get information now.

Anonymous
2021年05月21日
<a href="https://5bz.ru/">база предприятий казахстана</a>

Anonymous
2021年06月02日
Drugs information for patients. Cautions.
<a href="https://erythromycin4u.top">erythromycin no prescription</a> in US
All what you want to know about drugs. Read here.