今回は、ソフトウェア関係の記事になります。
音声の作成について
「マロン」の音声は、既存のロックシード音声から合成したものです。合成方法は至ってアナログな手法で、各ロックシードの音声をPCに取り込み、サウンド編集ソフトのAudacityで切り貼りしています。
なお、今回の「マロン」音声作成に際し、音源としてマツボックリ、マンゴー、メロン、バロン、ドライブ(「トライドロン」の音声)のロックシードを購入し、複数パターンの音声を合成して検討しましたが、最終的にマツボックリロックシードの「マ」とメロンロックシードの「ロン」を採用しました。
「マロン」の音声が完成したら、後は録音した変身音や必殺技音の果実名部分を、サウンド編集ソフトでマロンと差し替えればOKなのですが、必殺技はともかく、変身音は果実名と音楽が被るロックシードが多く、こちらも結局、果実名に音楽が被ってなかったメロンロックシードの音声を使用することになりました。
Arduinoスケッチの作成について
Arduinoのスケッチ(プログラム)です。以前作ったオリジナルガシャットのスケッチを流用し、オリジナルロックシード用に作り直しました。
なお、作製当初は、LEDをスピーカに接続して発光させる計画だったのですが、DXロックシードの内部にトランジスタ等を仕込む余裕がなかったため、急遽、ヒダカ様のオリジナルライドウォッチのLED発光処理部分を我が家の開発環境に合わせて改造したものを使用させてもらいました。
ボタン処理について
ロックシードのスイッチ(ボタン)認識は4つあり、開錠ボタン、主ボタン、武器認識ボタン、ベルト認識ボタンの4つです。このうち、開錠ボタンだけは特殊で、他のボタンと同時押しした時の処理が必要ないため、スケッチ上でも別処理にしてあります。
その他の処理について
細かいところだと、変身音声再生中に主ボタンが押されても必殺技処理に移らない等、色々あるのですが、今回はジオウの鎧武回中に完成させることが目的のひとつだったので、DX版の機能が完全に再現されているわけではありませんのでご注意ください。(可能な限り導入はしましたが…)スケッチ本文について
ほぼいつものお約束ですが、このスケッチで使用しているDFPlayer-Mini-mp3ライブラリは現在非推奨となっているらしいので、現行のDFRobotDFPlayerMiniライブラリに対応させるにはこのスケッチを更に改修する必要があります。以下、マロンロックシードで使用したスケッチです。
#include <SoftwareSerial.h> #include <DFPlayer_Mini_Mp3.h> SoftwareSerial mySerial(2, 3); // RX, TX #define ON LOW #define OFF HIGH #define N_BUTTON 3 #define BUTTON_1_PIN 4 // 開錠スイッチ #define LED_PIN 5 #define BUTTON_2_PIN 6 // 主ボタン #define BUTTON_3_PIN 7 // 武器ピン認識 #define BUTTON_4_PIN 8 // ベルトピン認識 #define STAND_BY 0 #define READY 1 // 電源ON音声 #define UNLOCK 2 #define SE1 3 // SE crack1 #define SE2 4 // SE battle_start #define SE3 5 // SE you_win #define SE4 6 // SE you_lose #define SE5 7 // SE lank_up #define SE6 8 // SE crack2 // #define SE7 9 // 予備 #define ROCKSEED_SET 10 #define ROCKSEED_RELEASE 11 #define TRANSFORM 12 #define SQUASH 13 #define AU_LAIT 14 #define SPARKING 15 #define CHARGE 16 #define POWER 17 #define JIMBAR 18 #define JIMBAR_SQUASH 19 #define JIMBAR_AU_LAIT 20 #define JIMBAR_SPARKING 21 const uint8_t OFF_OFF_OFF[] = {OFF, OFF, OFF}; const uint8_t ON_OFF_OFF[] = {ON , OFF, OFF}; const uint8_t OFF_ON_OFF[] = {OFF, ON , OFF}; const uint8_t ON_ON_OFF[] = {ON , ON , OFF}; const uint8_t OFF_OFF_ON[] = {OFF, OFF, ON }; const uint8_t ON_OFF_ON[] = {ON , OFF, ON }; const uint8_t OFF_ON_ON[] = {OFF, ON , ON }; const uint8_t ON_ON_ON[] = {ON , ON , ON }; uint8_t before_sw1 = OFF; uint8_t sw1 = OFF; uint8_t before_state[] = {OFF, OFF, OFF}; uint8_t state[] = {OFF, OFF, OFF}; uint8_t before_action = STAND_BY; uint8_t action = STAND_BY; uint8_t SE_ID = 0; uint8_t randNumber = 0; // ランダム再生対応 uint8_t special_ID = 0; // 必殺技判別 0:スカッシュ 1:オーレ 2:スパーキング boolean transform_flag = false; // 変身フラグ unsigned long transform_time = 0; // 変身時間計測 unsigned long special_time = 0; // 必殺時間計測 // add-start #define LED_COUNT_MAX 1500 // LOOP_INTERVAL_MSが20msで、30sまでの発光定義を想定 #define LED_BRIGHTNESS 255 // 255が上限値 #define LOOP_INTERVAL_MS 20 uint16_t led_counter = LED_COUNT_MAX; unsigned long blink_time = 0; unsigned long prev_blink_time = 0; unsigned long inc_dim_start_time = 0; boolean is_lighting = false; boolean is_inc = true; void led_base_pattern_on(){ analogWrite(LED_PIN, LED_BRIGHTNESS); } void led_base_pattern_off(){ analogWrite(LED_PIN, 0); } /* void led_base_pattern_blink(int interval_ms){ unsigned long now = millis(); if(now - prev_blink_time >= interval_ms){ if(is_lighting){ analogWrite(LED_PIN, 0); }else{ analogWrite(LED_PIN, LED_BRIGHTNESS); } is_lighting = !is_lighting; prev_blink_time = now; } } */ void led_base_pattern_inc(int interval_ms, uint8_t steps){ unsigned long now = millis(); if(inc_dim_start_time == 0){ inc_dim_start_time = now; } int ms_per_step = interval_ms / steps; int current_step = (now - inc_dim_start_time) / ms_per_step; uint8_t l_step = LED_BRIGHTNESS/steps; analogWrite(LED_PIN, l_step*current_step); if(now - inc_dim_start_time > interval_ms - ms_per_step){ inc_dim_start_time = 0; } } void led_base_pattern_dim(int interval_ms, uint8_t steps){ unsigned long now = millis(); if(inc_dim_start_time == 0){ inc_dim_start_time = now; } int ms_per_step = interval_ms / steps; int current_step = (now - inc_dim_start_time) / ms_per_step; uint8_t l_step = LED_BRIGHTNESS/steps; analogWrite(LED_PIN, l_step*(steps-current_step)); if(now - inc_dim_start_time > interval_ms - ms_per_step){ inc_dim_start_time = 0; } } void led_base_pattern_blink_slowly(int interval_ms, uint8_t steps){ unsigned long now = millis(); if(inc_dim_start_time == 0){ inc_dim_start_time = now; } int ms_per_step = interval_ms / steps; int current_step = (now - inc_dim_start_time) / ms_per_step; uint8_t l_step = LED_BRIGHTNESS/steps; if(is_inc){ analogWrite(LED_PIN, l_step*current_step); }else{ analogWrite(LED_PIN, l_step*(steps-current_step)); } if(now - inc_dim_start_time > interval_ms - ms_per_step){ is_inc = !is_inc; inc_dim_start_time = 0; } } void led_pattern_unlock(uint16_t led_counter_ms){ if(led_counter_ms <= 100){ led_base_pattern_off();} else if(100 < led_counter_ms && led_counter_ms <= 300){ led_base_pattern_dim(200, 10);} else if(300 < led_counter_ms && led_counter_ms <= 400){ led_base_pattern_off();} else if(400 < led_counter_ms && led_counter_ms <= 600){ led_base_pattern_inc(200, 10);} else if(600 < led_counter_ms && led_counter_ms <= 900){ led_base_pattern_on();} else if(900 < led_counter_ms && led_counter_ms <= 1500){ led_base_pattern_dim(600, 30);} else if(1500 < led_counter_ms && led_counter_ms <= 1700){ led_base_pattern_off();} else if(1700 < led_counter_ms && led_counter_ms <= 2700){ led_base_pattern_blink_slowly(500, 25);} else{ led_base_pattern_off();} } void led_pattern_se1(uint16_t led_counter_ms){ if(led_counter_ms <= 100){ led_base_pattern_off();} else if(100 < led_counter_ms && led_counter_ms <= 2100){ led_base_pattern_blink_slowly(1000, 500);} else{ led_base_pattern_off();} } void led_pattern_se2(uint16_t led_counter_ms){ if(led_counter_ms <= 100){ led_base_pattern_off();} else if(100 < led_counter_ms && led_counter_ms <= 500){ led_base_pattern_dim(400, 20);} else if(500 < led_counter_ms && led_counter_ms <= 1100){ led_base_pattern_off();} else if(1100 < led_counter_ms && led_counter_ms <= 1500){ led_base_pattern_dim(400, 20);} else if(1500 < led_counter_ms && led_counter_ms <= 2100){ led_base_pattern_off();} else if(2100 < led_counter_ms && led_counter_ms <= 2500){ led_base_pattern_dim(400, 20);} else if(2500 < led_counter_ms && led_counter_ms <= 2600){ led_base_pattern_off();} else if(2600 < led_counter_ms && led_counter_ms <= 2800){ led_base_pattern_on();} else if(2800 < led_counter_ms && led_counter_ms <= 3400){ led_base_pattern_dim(600, 30);} else if(3400 < led_counter_ms && led_counter_ms <= 3500){ led_base_pattern_inc(100, 5);} else if(3500 < led_counter_ms && led_counter_ms <= 3900){ led_base_pattern_on();} else if(3900 < led_counter_ms && led_counter_ms <= 4500){ led_base_pattern_dim(600, 30);} else{ led_base_pattern_off();} } void led_pattern_se3(uint16_t led_counter_ms){ if(led_counter_ms <= 100){ led_base_pattern_off();} else if(100 < led_counter_ms && led_counter_ms <= 300){ led_base_pattern_dim(200, 10);} else if(300 < led_counter_ms && led_counter_ms <= 400){ led_base_pattern_inc(100, 5);} else if(400 < led_counter_ms && led_counter_ms <= 1000){ led_base_pattern_on();} else if(1000 < led_counter_ms && led_counter_ms <= 2000){ led_base_pattern_dim(1000, 50);} else if(2000 < led_counter_ms && led_counter_ms <= 2400){ led_base_pattern_off();} else if(2400 < led_counter_ms && led_counter_ms <= 2500){ led_base_pattern_inc(100, 5);} else if(2500 < led_counter_ms && led_counter_ms <= 2600){ led_base_pattern_on();} else if(2600 < led_counter_ms && led_counter_ms <= 2800){ led_base_pattern_dim(200, 10);} else if(2800 < led_counter_ms && led_counter_ms <= 2900){ led_base_pattern_off();} else if(2900 < led_counter_ms && led_counter_ms <= 3100){ led_base_pattern_inc(200, 10);} else if(3100 < led_counter_ms && led_counter_ms <= 3500){ led_base_pattern_dim(400, 20);} else{ led_base_pattern_off();} } void led_pattern_se4(uint16_t led_counter_ms){ if(led_counter_ms <= 100){ led_base_pattern_off();} else if(100 < led_counter_ms && led_counter_ms <= 300){ led_base_pattern_dim(200, 10);} else if(300 < led_counter_ms && led_counter_ms <= 400){ led_base_pattern_inc(100, 5);} else if(400 < led_counter_ms && led_counter_ms <= 1000){ led_base_pattern_on();} else if(1000 < led_counter_ms && led_counter_ms <= 2000){ led_base_pattern_dim(1000, 50);} else if(2000 < led_counter_ms && led_counter_ms <= 2400){ led_base_pattern_off();} else if(2400 < led_counter_ms && led_counter_ms <= 2800){ led_base_pattern_blink_slowly(200, 10);} else if(2800 < led_counter_ms && led_counter_ms <= 2900){ led_base_pattern_off();} else if(2900 < led_counter_ms && led_counter_ms <= 3200){ led_base_pattern_inc(300, 15);} else if(3200 < led_counter_ms && led_counter_ms <= 3900){ led_base_pattern_dim(700, 35);} else{ led_base_pattern_off();} } void led_pattern_se5(uint16_t led_counter_ms){ if(led_counter_ms <= 100){ led_base_pattern_off();} else if(100 < led_counter_ms && led_counter_ms <= 300){ led_base_pattern_inc(200, 10);} else if(300 < led_counter_ms && led_counter_ms <= 800){ led_base_pattern_dim(500, 25);} else if(800 < led_counter_ms && led_counter_ms <= 900){ led_base_pattern_off();} else if(900 < led_counter_ms && led_counter_ms <= 1300){ led_base_pattern_dim(400, 20);} else{ led_base_pattern_off();} } void led_pattern_se6(uint16_t led_counter_ms){ if(led_counter_ms <= 100){ led_base_pattern_off();} else if(100 < led_counter_ms && led_counter_ms <= 1300){ led_base_pattern_blink_slowly(600, 30);} else{ led_base_pattern_off();} } void led_pattern_set(uint16_t led_counter_ms){ if(led_counter_ms <= 100){ led_base_pattern_off();} else if(100 < led_counter_ms && led_counter_ms <= 1700){ led_base_pattern_dim(1600, 80);} else{ led_base_pattern_off();} } void led_pattern_release(uint16_t led_counter_ms){ if(led_counter_ms <= 100){ led_base_pattern_off();} else if(100 < led_counter_ms && led_counter_ms <= 300){ led_base_pattern_blink_slowly(100, 5);} else if(300 < led_counter_ms && led_counter_ms <= 400){ led_base_pattern_inc(100, 5);} else if(400 < led_counter_ms && led_counter_ms <= 600){ led_base_pattern_on();} else if(600 < led_counter_ms && led_counter_ms <= 1900){ led_base_pattern_dim(1600, 80);} else{ led_base_pattern_off();} } void led_pattern_transform(uint16_t led_counter_ms){ if(led_counter_ms <= 100){ led_base_pattern_off();} else if(100 < led_counter_ms && led_counter_ms <= 300){ led_base_pattern_on();} else if(300 < led_counter_ms && led_counter_ms <= 600){ led_base_pattern_dim(300, 15);} else if(600 < led_counter_ms && led_counter_ms <= 1200){ led_base_pattern_off();} else if(1200 < led_counter_ms && led_counter_ms <= 1600){ led_base_pattern_inc(400, 20);} else if(1600 < led_counter_ms && led_counter_ms <= 1900){ led_base_pattern_on();} else if(1900 < led_counter_ms && led_counter_ms <= 2100){ led_base_pattern_dim(200, 10);} else if(2100 < led_counter_ms && led_counter_ms <= 2300){ led_base_pattern_inc(200, 10);} else if(2300 < led_counter_ms && led_counter_ms <= 2600){ led_base_pattern_on();} else if(2600 < led_counter_ms && led_counter_ms <= 2800){ led_base_pattern_dim(200, 10);} else if(2800 < led_counter_ms && led_counter_ms <= 2900){ led_base_pattern_inc(100, 5);} else if(2900 < led_counter_ms && led_counter_ms <= 3200){ led_base_pattern_on();} else if(3200 < led_counter_ms && led_counter_ms <= 3500){ led_base_pattern_dim(300, 15);} else if(3500 < led_counter_ms && led_counter_ms <= 3700){ led_base_pattern_inc(200, 10);} else if(3700 < led_counter_ms && led_counter_ms <= 3900){ led_base_pattern_on();} else if(3900 < led_counter_ms && led_counter_ms <= 4200){ led_base_pattern_dim(300, 15);} else if(4200 < led_counter_ms && led_counter_ms <= 4400){ led_base_pattern_inc(200, 10);} else if(4400 < led_counter_ms && led_counter_ms <= 4700){ led_base_pattern_on();} else if(4700 < led_counter_ms && led_counter_ms <= 5100){ led_base_pattern_dim(400, 20);} else if(5100 < led_counter_ms && led_counter_ms <= 5300){ led_base_pattern_inc(200, 10);} else if(5300 < led_counter_ms && led_counter_ms <= 6500){ led_base_pattern_on();} else if(6500 < led_counter_ms && led_counter_ms <= 8500){ led_base_pattern_dim(2000, 100);} else{ led_base_pattern_off();} } void led_pattern_squash(uint16_t led_counter_ms){ if(led_counter_ms <= 100){ led_base_pattern_off();} else if(100 < led_counter_ms && led_counter_ms <= 300){ led_base_pattern_on();} else if(300 < led_counter_ms && led_counter_ms <= 600){ led_base_pattern_dim(300, 15);} else if(600 < led_counter_ms && led_counter_ms <= 1200){ led_base_pattern_off();} else if(1200 < led_counter_ms && led_counter_ms <= 1400){ led_base_pattern_inc(200, 10);} else if(1400 < led_counter_ms && led_counter_ms <= 1600){ led_base_pattern_on();} else if(1600 < led_counter_ms && led_counter_ms <= 1900){ led_base_pattern_dim(300, 15);} else if(1900 < led_counter_ms && led_counter_ms <= 2200){ led_base_pattern_inc(300, 15);} else if(2200 < led_counter_ms && led_counter_ms <= 2500){ led_base_pattern_on();} else if(2500 < led_counter_ms && led_counter_ms <= 3000){ led_base_pattern_dim(500, 25);} else if(3000 < led_counter_ms && led_counter_ms <= 3100){ led_base_pattern_off();} else if(3100 < led_counter_ms && led_counter_ms <= 3500){ led_base_pattern_inc(400, 20);} else if(3500 < led_counter_ms && led_counter_ms <= 4000){ led_base_pattern_on();} else if(4000 < led_counter_ms && led_counter_ms <= 4600){ led_base_pattern_dim(600, 30);} else if(4600 < led_counter_ms && led_counter_ms <= 4900){ led_base_pattern_inc(300, 15);} else if(4900 < led_counter_ms && led_counter_ms <= 5200){ led_base_pattern_on();} else if(5200 < led_counter_ms && led_counter_ms <= 5600){ led_base_pattern_dim(400, 20);} else if(5600 < led_counter_ms && led_counter_ms <= 5800){ led_base_pattern_inc(200, 10);} else if(5800 < led_counter_ms && led_counter_ms <= 6000){ led_base_pattern_on();} else if(6000 < led_counter_ms && led_counter_ms <= 6300){ led_base_pattern_dim(300, 15);} else if(6300 < led_counter_ms && led_counter_ms <= 6500){ led_base_pattern_inc(200, 10);} else if(6500 < led_counter_ms && led_counter_ms <= 7300){ led_base_pattern_on();} else if(7300 < led_counter_ms && led_counter_ms <= 8800){ led_base_pattern_dim(1500, 75);} else{ led_base_pattern_off();} } void led_pattern_au_lait(uint16_t led_counter_ms){ if(led_counter_ms <= 100){ led_base_pattern_off();} else if(100 < led_counter_ms && led_counter_ms <= 300){ led_base_pattern_on();} else if(300 < led_counter_ms && led_counter_ms <= 600){ led_base_pattern_dim(300, 15);} else if(600 < led_counter_ms && led_counter_ms <= 1200){ led_base_pattern_off();} else if(1200 < led_counter_ms && led_counter_ms <= 1400){ led_base_pattern_inc(200, 10);} else if(1400 < led_counter_ms && led_counter_ms <= 1600){ led_base_pattern_on();} else if(1600 < led_counter_ms && led_counter_ms <= 1900){ led_base_pattern_dim(300, 15);} else if(1900 < led_counter_ms && led_counter_ms <= 2200){ led_base_pattern_inc(300, 15);} else if(2200 < led_counter_ms && led_counter_ms <= 2500){ led_base_pattern_on();} else if(2500 < led_counter_ms && led_counter_ms <= 3000){ led_base_pattern_dim(500, 25);} else if(3000 < led_counter_ms && led_counter_ms <= 3100){ led_base_pattern_off();} else if(3100 < led_counter_ms && led_counter_ms <= 3300){ led_base_pattern_inc(200, 10);} else if(3300 < led_counter_ms && led_counter_ms <= 3500){ led_base_pattern_on();} else if(3500 < led_counter_ms && led_counter_ms <= 3900){ led_base_pattern_dim(400, 20);} else if(3900 < led_counter_ms && led_counter_ms <= 4500){ led_base_pattern_inc(600, 30);} else if(4500 < led_counter_ms && led_counter_ms <= 4900){ led_base_pattern_on();} else if(4900 < led_counter_ms && led_counter_ms <= 5900){ led_base_pattern_dim(1000, 50);} else{ led_base_pattern_off();} } void led_pattern_sparking(uint16_t led_counter_ms){ if(led_counter_ms <= 100){ led_base_pattern_off();} else if(100 < led_counter_ms && led_counter_ms <= 300){ led_base_pattern_on();} else if(300 < led_counter_ms && led_counter_ms <= 600){ led_base_pattern_dim(300, 15);} else if(600 < led_counter_ms && led_counter_ms <= 1200){ led_base_pattern_off();} else if(1200 < led_counter_ms && led_counter_ms <= 1400){ led_base_pattern_inc(200, 10);} else if(1400 < led_counter_ms && led_counter_ms <= 1600){ led_base_pattern_on();} else if(1600 < led_counter_ms && led_counter_ms <= 1900){ led_base_pattern_dim(300, 15);} else if(1900 < led_counter_ms && led_counter_ms <= 2100){ led_base_pattern_inc(200, 10);} else if(2100 < led_counter_ms && led_counter_ms <= 2200){ led_base_pattern_on();} else if(2200 < led_counter_ms && led_counter_ms <= 2400){ led_base_pattern_dim(200, 10);} else if(2400 < led_counter_ms && led_counter_ms <= 2600){ led_base_pattern_inc(200, 10);} else if(2600 < led_counter_ms && led_counter_ms <= 2800){ led_base_pattern_on();} else if(2800 < led_counter_ms && led_counter_ms <= 3100){ led_base_pattern_dim(300, 15);} else if(3100 < led_counter_ms && led_counter_ms <= 3300){ led_base_pattern_off();} else if(3300 < led_counter_ms && led_counter_ms <= 3400){ led_base_pattern_inc(100, 5);} else if(3400 < led_counter_ms && led_counter_ms <= 3500){ led_base_pattern_on();} else if(3500 < led_counter_ms && led_counter_ms <= 3700){ led_base_pattern_dim(200, 10);} else if(3700 < led_counter_ms && led_counter_ms <= 3800){ led_base_pattern_off();} else if(3800 < led_counter_ms && led_counter_ms <= 4000){ led_base_pattern_inc(200, 10);} else if(4000 < led_counter_ms && led_counter_ms <= 4200){ led_base_pattern_on();} else if(4200 < led_counter_ms && led_counter_ms <= 4400){ led_base_pattern_dim(200, 10);} else if(4400 < led_counter_ms && led_counter_ms <= 4600){ led_base_pattern_inc(200, 10);} else if(4600 < led_counter_ms && led_counter_ms <= 4800){ led_base_pattern_on();} else if(4800 < led_counter_ms && led_counter_ms <= 5000){ led_base_pattern_dim(200, 10);} else if(5000 < led_counter_ms && led_counter_ms <= 5200){ led_base_pattern_inc(200, 10);} else if(5200 < led_counter_ms && led_counter_ms <= 5300){ led_base_pattern_on();} else if(5300 < led_counter_ms && led_counter_ms <= 5500){ led_base_pattern_dim(200, 10);} else if(5500 < led_counter_ms && led_counter_ms <= 5800){ led_base_pattern_inc(300, 15);} else if(5800 < led_counter_ms && led_counter_ms <= 6000){ led_base_pattern_on();} else if(6000 < led_counter_ms && led_counter_ms <= 6300){ led_base_pattern_dim(300, 15);} else if(6300 < led_counter_ms && led_counter_ms <= 6400){ led_base_pattern_inc(100, 5);} else if(6400 < led_counter_ms && led_counter_ms <= 6600){ led_base_pattern_on();} else if(6600 < led_counter_ms && led_counter_ms <= 7200){ led_base_pattern_dim(600, 30);} else if(7200 < led_counter_ms && led_counter_ms <= 7500){ led_base_pattern_inc(300, 15);} else if(7500 < led_counter_ms && led_counter_ms <= 8300){ led_base_pattern_on();} else if(8300 < led_counter_ms && led_counter_ms <= 9500){ led_base_pattern_dim(1200, 60);} else{ led_base_pattern_off();} } void led_pattern_charge(uint16_t led_counter_ms){ if(led_counter_ms <= 100){ led_base_pattern_off();} else if(100 < led_counter_ms && led_counter_ms <= 200){ led_base_pattern_inc(100, 5);} else if(200 < led_counter_ms && led_counter_ms <= 500){ led_base_pattern_on();} else if(500 < led_counter_ms && led_counter_ms <= 700){ led_base_pattern_dim(200, 10);} else if(700 < led_counter_ms && led_counter_ms <= 1000){ led_base_pattern_inc(300, 15);} else if(1000 < led_counter_ms && led_counter_ms <= 1400){ led_base_pattern_on();} else if(1400 < led_counter_ms && led_counter_ms <= 1800){ led_base_pattern_dim(400, 20);} else if(1800 < led_counter_ms && led_counter_ms <= 4100){ led_base_pattern_off();} else if(4100 < led_counter_ms && led_counter_ms <= 4300){ led_base_pattern_inc(200, 10);} else if(4300 < led_counter_ms && led_counter_ms <= 4500){ led_base_pattern_on();} else if(4500 < led_counter_ms && led_counter_ms <= 4700){ led_base_pattern_dim(200, 10);} else if(4700 < led_counter_ms && led_counter_ms <= 4800){ led_base_pattern_off();} else if(4800 < led_counter_ms && led_counter_ms <= 5000){ led_base_pattern_blink_slowly(100, 5);} else if(5000 < led_counter_ms && led_counter_ms <= 5200){ led_base_pattern_inc(200, 10);} else if(5200 < led_counter_ms && led_counter_ms <= 5400){ led_base_pattern_on();} else if(5400 < led_counter_ms && led_counter_ms <= 6000){ led_base_pattern_dim(600, 30);} else{ led_base_pattern_off();} } void led_pattern_power(uint16_t led_counter_ms){ if(led_counter_ms <= 100){ led_base_pattern_off();} else if(100 < led_counter_ms && led_counter_ms <= 200){ led_base_pattern_inc(100, 5);} else if(200 < led_counter_ms && led_counter_ms <= 500){ led_base_pattern_on();} else if(500 < led_counter_ms && led_counter_ms <= 700){ led_base_pattern_dim(200, 10);} else if(700 < led_counter_ms && led_counter_ms <= 900){ led_base_pattern_inc(200, 10);} else if(900 < led_counter_ms && led_counter_ms <= 1000){ led_base_pattern_on();} else if(1000 < led_counter_ms && led_counter_ms <= 1200){ led_base_pattern_dim(200, 10);} else if(1200 < led_counter_ms && led_counter_ms <= 1400){ led_base_pattern_inc(200, 10);} else if(1400 < led_counter_ms && led_counter_ms <= 1600){ led_base_pattern_on();} else if(1600 < led_counter_ms && led_counter_ms <= 1800){ led_base_pattern_dim(200, 10);} else{ led_base_pattern_off();} } void led_pattern_jimbar(uint16_t led_counter_ms){ if(led_counter_ms <= 100){ led_base_pattern_off();} else if(100 < led_counter_ms && led_counter_ms <= 300){ led_base_pattern_on();} else if(300 < led_counter_ms && led_counter_ms <= 600){ led_base_pattern_dim(300, 15);} else if(600 < led_counter_ms && led_counter_ms <= 6400){ led_base_pattern_off();} else if(6400 < led_counter_ms && led_counter_ms <= 7000){ led_base_pattern_blink_slowly(300, 15);} else if(7000 < led_counter_ms && led_counter_ms <= 7200){ led_base_pattern_off();} else if(7200 < led_counter_ms && led_counter_ms <= 7600){ led_base_pattern_inc(400, 20);} else if(7600 < led_counter_ms && led_counter_ms <= 7900){ led_base_pattern_on();} else if(7900 < led_counter_ms && led_counter_ms <= 8100){ led_base_pattern_dim(200, 10);} else if(8100 < led_counter_ms && led_counter_ms <= 8300){ led_base_pattern_inc(200, 10);} else if(8300 < led_counter_ms && led_counter_ms <= 8600){ led_base_pattern_on();} else if(8600 < led_counter_ms && led_counter_ms <= 8800){ led_base_pattern_dim(200, 10);} else if(8800 < led_counter_ms && led_counter_ms <= 8900){ led_base_pattern_inc(100, 5);} else if(8900 < led_counter_ms && led_counter_ms <= 9200){ led_base_pattern_on();} else if(9200 < led_counter_ms && led_counter_ms <= 9500){ led_base_pattern_dim(300, 15);} else if(9500 < led_counter_ms && led_counter_ms <= 9700){ led_base_pattern_inc(200, 10);} else if(9700 < led_counter_ms && led_counter_ms <= 9900){ led_base_pattern_on();} else if(9900 < led_counter_ms && led_counter_ms <= 10200){ led_base_pattern_dim(300, 15);} else if(10200 < led_counter_ms && led_counter_ms <= 10400){ led_base_pattern_inc(200, 10);} else if(10400 < led_counter_ms && led_counter_ms <= 10700){ led_base_pattern_on();} else if(10700 < led_counter_ms && led_counter_ms <= 11100){ led_base_pattern_dim(400, 20);} else if(11100 < led_counter_ms && led_counter_ms <= 11300){ led_base_pattern_inc(200, 10);} else if(11300 < led_counter_ms && led_counter_ms <= 12500){ led_base_pattern_on();} else if(12500 < led_counter_ms && led_counter_ms <= 14500){ led_base_pattern_dim(2000, 100);} else{ led_base_pattern_off();} } void led_pattern_jimbar_squash(uint16_t led_counter_ms){ if(led_counter_ms <= 100){ led_base_pattern_off();} else if(100 < led_counter_ms && led_counter_ms <= 300){ led_base_pattern_on();} else if(300 < led_counter_ms && led_counter_ms <= 600){ led_base_pattern_dim(300, 15);} else if(600 < led_counter_ms && led_counter_ms <= 4300){ led_base_pattern_off();} else if(4300 < led_counter_ms && led_counter_ms <= 4500){ led_base_pattern_inc(200, 10);} else if(4500 < led_counter_ms && led_counter_ms <= 4700){ led_base_pattern_on();} else if(4700 < led_counter_ms && led_counter_ms <= 5000){ led_base_pattern_dim(300, 15);} else if(5000 < led_counter_ms && led_counter_ms <= 5300){ led_base_pattern_inc(300, 15);} else if(5300 < led_counter_ms && led_counter_ms <= 5600){ led_base_pattern_on();} else if(5600 < led_counter_ms && led_counter_ms <= 6100){ led_base_pattern_dim(500, 25);} else if(6100 < led_counter_ms && led_counter_ms <= 6200){ led_base_pattern_off();} else if(6200 < led_counter_ms && led_counter_ms <= 6600){ led_base_pattern_inc(400, 20);} else if(6600 < led_counter_ms && led_counter_ms <= 7100){ led_base_pattern_on();} else if(7100 < led_counter_ms && led_counter_ms <= 7700){ led_base_pattern_dim(600, 30);} else if(7700 < led_counter_ms && led_counter_ms <= 8000){ led_base_pattern_inc(300, 15);} else if(8000 < led_counter_ms && led_counter_ms <= 8300){ led_base_pattern_on();} else if(8300 < led_counter_ms && led_counter_ms <= 8700){ led_base_pattern_dim(400, 20);} else if(8700 < led_counter_ms && led_counter_ms <= 8900){ led_base_pattern_inc(200, 10);} else if(8900 < led_counter_ms && led_counter_ms <= 9100){ led_base_pattern_on();} else if(9100 < led_counter_ms && led_counter_ms <= 9400){ led_base_pattern_dim(300, 15);} else if(9400 < led_counter_ms && led_counter_ms <= 9600){ led_base_pattern_inc(200, 10);} else if(9600 < led_counter_ms && led_counter_ms <= 10400){ led_base_pattern_on();} else if(10400 < led_counter_ms && led_counter_ms <= 11900){ led_base_pattern_dim(1500, 75);} else{ led_base_pattern_off();} } void led_pattern_jimbar_au_lait(uint16_t led_counter_ms){ if(led_counter_ms <= 100){ led_base_pattern_off();} else if(100 < led_counter_ms && led_counter_ms <= 300){ led_base_pattern_on();} else if(300 < led_counter_ms && led_counter_ms <= 600){ led_base_pattern_dim(300, 15);} else if(600 < led_counter_ms && led_counter_ms <= 4300){ led_base_pattern_off();} else if(4300 < led_counter_ms && led_counter_ms <= 4500){ led_base_pattern_inc(200, 10);} else if(4500 < led_counter_ms && led_counter_ms <= 4700){ led_base_pattern_on();} else if(4700 < led_counter_ms && led_counter_ms <= 5000){ led_base_pattern_dim(300, 15);} else if(5000 < led_counter_ms && led_counter_ms <= 5300){ led_base_pattern_inc(300, 15);} else if(5300 < led_counter_ms && led_counter_ms <= 5600){ led_base_pattern_on();} else if(5600 < led_counter_ms && led_counter_ms <= 6100){ led_base_pattern_dim(500, 25);} else if(6100 < led_counter_ms && led_counter_ms <= 6200){ led_base_pattern_off();} else if(6200 < led_counter_ms && led_counter_ms <= 6400){ led_base_pattern_inc(200, 10);} else if(6400 < led_counter_ms && led_counter_ms <= 6600){ led_base_pattern_on();} else if(6600 < led_counter_ms && led_counter_ms <= 7000){ led_base_pattern_dim(400, 20);} else if(7000 < led_counter_ms && led_counter_ms <= 7600){ led_base_pattern_inc(600, 30);} else if(7600 < led_counter_ms && led_counter_ms <= 8000){ led_base_pattern_on();} else if(8000 < led_counter_ms && led_counter_ms <= 9000){ led_base_pattern_dim(1000, 50);} else{ led_base_pattern_off();} } void led_pattern_jimbar_sparking(uint16_t led_counter_ms){ if(led_counter_ms <= 100){ led_base_pattern_off();} else if(100 < led_counter_ms && led_counter_ms <= 300){ led_base_pattern_on();} else if(300 < led_counter_ms && led_counter_ms <= 600){ led_base_pattern_dim(300, 15);} else if(600 < led_counter_ms && led_counter_ms <= 4300){ led_base_pattern_off();} else if(4300 < led_counter_ms && led_counter_ms <= 4500){ led_base_pattern_inc(200, 10);} else if(4500 < led_counter_ms && led_counter_ms <= 4700){ led_base_pattern_on();} else if(4700 < led_counter_ms && led_counter_ms <= 5000){ led_base_pattern_dim(300, 15);} else if(5000 < led_counter_ms && led_counter_ms <= 5200){ led_base_pattern_inc(200, 10);} else if(5200 < led_counter_ms && led_counter_ms <= 5300){ led_base_pattern_on();} else if(5300 < led_counter_ms && led_counter_ms <= 5500){ led_base_pattern_dim(200, 10);} else if(5500 < led_counter_ms && led_counter_ms <= 5700){ led_base_pattern_inc(200, 10);} else if(5700 < led_counter_ms && led_counter_ms <= 5900){ led_base_pattern_on();} else if(5900 < led_counter_ms && led_counter_ms <= 6200){ led_base_pattern_dim(300, 15);} else if(6200 < led_counter_ms && led_counter_ms <= 6400){ led_base_pattern_off();} else if(6400 < led_counter_ms && led_counter_ms <= 6500){ led_base_pattern_inc(100, 5);} else if(6500 < led_counter_ms && led_counter_ms <= 6600){ led_base_pattern_on();} else if(6600 < led_counter_ms && led_counter_ms <= 6800){ led_base_pattern_dim(200, 10);} else if(6800 < led_counter_ms && led_counter_ms <= 6900){ led_base_pattern_off();} else if(6900 < led_counter_ms && led_counter_ms <= 7100){ led_base_pattern_inc(200, 10);} else if(7100 < led_counter_ms && led_counter_ms <= 7300){ led_base_pattern_on();} else if(7300 < led_counter_ms && led_counter_ms <= 7500){ led_base_pattern_dim(200, 10);} else if(7500 < led_counter_ms && led_counter_ms <= 7700){ led_base_pattern_inc(200, 10);} else if(7700 < led_counter_ms && led_counter_ms <= 7900){ led_base_pattern_on();} else if(7900 < led_counter_ms && led_counter_ms <= 8100){ led_base_pattern_dim(200, 10);} else if(8100 < led_counter_ms && led_counter_ms <= 8300){ led_base_pattern_inc(200, 10);} else if(8300 < led_counter_ms && led_counter_ms <= 8400){ led_base_pattern_on();} else if(8400 < led_counter_ms && led_counter_ms <= 8600){ led_base_pattern_dim(200, 10);} else if(8600 < led_counter_ms && led_counter_ms <= 8900){ led_base_pattern_inc(300, 15);} else if(8900 < led_counter_ms && led_counter_ms <= 9100){ led_base_pattern_on();} else if(9100 < led_counter_ms && led_counter_ms <= 9400){ led_base_pattern_dim(300, 15);} else if(9400 < led_counter_ms && led_counter_ms <= 9500){ led_base_pattern_inc(100, 5);} else if(9500 < led_counter_ms && led_counter_ms <= 9700){ led_base_pattern_on();} else if(9700 < led_counter_ms && led_counter_ms <= 10300){ led_base_pattern_dim(600, 30);} else if(10300 < led_counter_ms && led_counter_ms <= 10600){ led_base_pattern_inc(300, 15);} else if(10600 < led_counter_ms && led_counter_ms <= 11400){ led_base_pattern_on();} else if(11400 < led_counter_ms && led_counter_ms <= 12600){ led_base_pattern_dim(1200, 60);} else{ led_base_pattern_off();} } void flash_led(){ if(before_action != action){ led_counter = 0; } uint16_t led_counter_ms = led_counter * LOOP_INTERVAL_MS; // LEDはms単位で制御 switch(action){ case UNLOCK: led_pattern_unlock(led_counter_ms); break; case SE1: led_pattern_se1(led_counter_ms); break; case SE2: led_pattern_se2(led_counter_ms); break; case SE3: led_pattern_se3(led_counter_ms); break; case SE4: led_pattern_se4(led_counter_ms); break; case SE5: led_pattern_se5(led_counter_ms); break; case SE6: led_pattern_se6(led_counter_ms); break; case ROCKSEED_SET: led_pattern_set(led_counter_ms); break; case ROCKSEED_RELEASE: led_pattern_release(led_counter_ms); break; case TRANSFORM: led_pattern_transform(led_counter_ms); break; case SQUASH: led_pattern_squash(led_counter_ms); break; case AU_LAIT: led_pattern_au_lait(led_counter_ms); break; case SPARKING: led_pattern_sparking(led_counter_ms); break; case CHARGE: led_pattern_charge(led_counter_ms); break; case POWER: led_pattern_power(led_counter_ms); break; case JIMBAR: led_pattern_jimbar(led_counter_ms); break; case JIMBAR_SQUASH: led_pattern_jimbar_squash(led_counter_ms); break; case JIMBAR_AU_LAIT: led_pattern_jimbar_au_lait(led_counter_ms); break; case JIMBAR_SPARKING: led_pattern_jimbar_sparking(led_counter_ms); break; default: ; } if(led_counter < LED_COUNT_MAX){ led_counter++; } } // add-end void flag_clear(){ transform_flag = false; SE_ID = 0; special_ID = 0; } void setup () { mySerial.begin (9600); mp3_set_serial (mySerial); //set softwareSerial for DFPlayer-mini mp3 module mp3_set_volume (30); pinMode(LED_PIN, OUTPUT); pinMode(BUTTON_1_PIN, INPUT_PULLUP); pinMode(BUTTON_2_PIN, INPUT_PULLUP); pinMode(BUTTON_3_PIN, INPUT_PULLUP); pinMode(BUTTON_4_PIN, INPUT_PULLUP); } void loop(){ sw1 = digitalRead(BUTTON_1_PIN); state[0] = digitalRead(BUTTON_2_PIN); state[1] = digitalRead(BUTTON_3_PIN); state[2] = digitalRead(BUTTON_4_PIN); if(before_sw1 == OFF){ if(sw1 == OFF){ ; }else if(sw1 == ON){ led_counter = LED_COUNT_MAX; before_action = STAND_BY; // 擬似的に状態変化を起こす action = UNLOCK; mp3_play(action); led_counter = 0; flag_clear(); } } if(memcmp(before_state, OFF_OFF_OFF, N_BUTTON) == 0){ if(memcmp(state, OFF_OFF_OFF, N_BUTTON) == 0){ ; }else if(memcmp(state, ON_OFF_OFF, N_BUTTON) == 0){ // 単品遊び switch(SE_ID){ // 音声処理 case 0: action = SE1; mp3_play(action); led_counter = 0; SE_ID++; break; case 1: action = SE2; mp3_play(action); led_counter = 0; SE_ID++; break; case 2: randNumber = random(9); if(randNumber >= 4){ action = SE3; mp3_play(action); led_counter = 0; randNumber = random(9); if(randNumber >= 4){ SE_ID = 4; }else{ SE_ID = 5; } }else{ action = SE4; mp3_play(action); led_counter = 0; SE_ID = 5; } break; case 4: action = SE5; mp3_play(action); led_counter = 0; SE_ID = 5; break; case 5: action = SE6; mp3_play(action); led_counter = 0; SE_ID = 0; break; } }else if(memcmp(state, OFF_ON_OFF, N_BUTTON) == 0){ action = ROCKSEED_SET; mp3_play(action); led_counter = 0; }else if(memcmp(state, ON_ON_OFF, N_BUTTON) == 0){ ; }else if(memcmp(state, OFF_OFF_ON, N_BUTTON) == 0){ action = ROCKSEED_SET; mp3_play(action); led_counter = 0; }else if(memcmp(state, ON_OFF_ON, N_BUTTON) == 0){ ; }else if(memcmp(state, OFF_ON_ON, N_BUTTON) == 0){ action = ROCKSEED_SET; mp3_play(action); led_counter = 0; }else if(memcmp(state, ON_ON_ON, N_BUTTON) == 0){ ; } }else if(memcmp(before_state, ON_OFF_OFF, N_BUTTON) == 0){ if(memcmp(state, OFF_OFF_OFF, N_BUTTON) == 0){ ; }else if(memcmp(state, ON_OFF_OFF, N_BUTTON) == 0){ ; }else if(memcmp(state, OFF_ON_OFF, N_BUTTON) == 0){ ; }else if(memcmp(state, ON_ON_OFF, N_BUTTON) == 0){ ; }else if(memcmp(state, OFF_OFF_ON, N_BUTTON) == 0){ ; }else if(memcmp(state, ON_OFF_ON, N_BUTTON) == 0){ ; }else if(memcmp(state, OFF_ON_ON, N_BUTTON) == 0){ ; }else if(memcmp(state, ON_ON_ON, N_BUTTON) == 0){ ; } }else if(memcmp(before_state, OFF_ON_OFF, N_BUTTON) == 0){ // 武器にセット if(memcmp(state, OFF_OFF_OFF, N_BUTTON) == 0){ action = ROCKSEED_RELEASE; mp3_play(action); led_counter = 0; flag_clear(); }else if(memcmp(state, ON_OFF_OFF, N_BUTTON) == 0){ ; }else if(memcmp(state, OFF_ON_OFF, N_BUTTON) == 0){ ; }else if(memcmp(state, ON_ON_OFF, N_BUTTON) == 0){ switch(transform_flag){ // 変身・必殺処理 case false: action = CHARGE; mp3_play(action); led_counter = 0; transform_flag = true; break; case true: unsigned long now = millis(); if(transform_time == 0){ transform_time = now; } if(now - transform_time >= 5000){ before_action = STAND_BY; // 擬似的に状態変化を起こす action = POWER; mp3_play(action); led_counter = 0; } break; } }else if(memcmp(state, OFF_OFF_ON, N_BUTTON) == 0){ ; }else if(memcmp(state, ON_OFF_ON, N_BUTTON) == 0){ ; }else if(memcmp(state, OFF_ON_ON, N_BUTTON) == 0){ ; }else if(memcmp(state, ON_ON_ON, N_BUTTON) == 0){ ; } }else if(memcmp(before_state, ON_ON_OFF, N_BUTTON) == 0){ if(memcmp(state, OFF_OFF_OFF, N_BUTTON) == 0){ action = ROCKSEED_RELEASE; mp3_play(action); led_counter = 0; flag_clear(); }else if(memcmp(state, ON_OFF_OFF, N_BUTTON) == 0){ ; }else if(memcmp(state, OFF_ON_OFF, N_BUTTON) == 0){ ; }else if(memcmp(state, ON_ON_OFF, N_BUTTON) == 0){ ; }else if(memcmp(state, OFF_OFF_ON, N_BUTTON) == 0){ ; }else if(memcmp(state, ON_OFF_ON, N_BUTTON) == 0){ ; }else if(memcmp(state, OFF_ON_ON, N_BUTTON) == 0){ ; }else if(memcmp(state, ON_ON_ON, N_BUTTON) == 0){ ; } }else if(memcmp(before_state, OFF_OFF_ON, N_BUTTON) == 0){ // ベルトにセット if(memcmp(state, OFF_OFF_OFF, N_BUTTON) == 0){ action = ROCKSEED_RELEASE; mp3_play(action); led_counter = 0; flag_clear(); }else if(memcmp(state, ON_OFF_OFF, N_BUTTON) == 0){ ; }else if(memcmp(state, OFF_ON_OFF, N_BUTTON) == 0){ ; }else if(memcmp(state, ON_ON_OFF, N_BUTTON) == 0){ ; }else if(memcmp(state, OFF_OFF_ON, N_BUTTON) == 0){ ; }else if(memcmp(state, ON_OFF_ON, N_BUTTON) == 0){ switch(transform_flag){ // 変身・必殺処理 case false: action = TRANSFORM; mp3_play(action); led_counter = 0; transform_flag = true; transform_time = millis(); break; case true: unsigned long now = millis(); if(now - transform_time >= 8500){ if(special_ID == 0){ // special_IDが0 action = SQUASH; mp3_play(action); led_counter = 0; special_ID++; special_time = now; }else if(special_ID == 1 && now - special_time <= 1000){ // special_IDが1かつ前回入力より1秒以内 action = AU_LAIT; mp3_play(action); led_counter = 0; special_ID++; special_time = now; }else if(special_ID == 2 && now - special_time <= 1000){ // special_IDが2かつ前回入力より1秒以内 action = SPARKING; mp3_play(action); led_counter = 0; special_time = now; }else{ action = SQUASH; mp3_play(action); led_counter = 0; special_ID = 1; special_time = now; } } break; } }else if(memcmp(state, OFF_ON_ON, N_BUTTON) == 0){ ; }else if(memcmp(state, ON_ON_ON, N_BUTTON) == 0){ ; } }else if(memcmp(before_state, ON_OFF_ON, N_BUTTON) == 0){ if(memcmp(state, OFF_OFF_OFF, N_BUTTON) == 0){ action = ROCKSEED_RELEASE; mp3_play(action); led_counter = 0; flag_clear(); }else if(memcmp(state, ON_OFF_OFF, N_BUTTON) == 0){ ; }else if(memcmp(state, OFF_ON_OFF, N_BUTTON) == 0){ ; }else if(memcmp(state, ON_ON_OFF, N_BUTTON) == 0){ ; }else if(memcmp(state, OFF_OFF_ON, N_BUTTON) == 0){ ; }else if(memcmp(state, ON_OFF_ON, N_BUTTON) == 0){ ; }else if(memcmp(state, OFF_ON_ON, N_BUTTON) == 0){ ; }else if(memcmp(state, ON_ON_ON, N_BUTTON) == 0){ ; } }else if(memcmp(before_state, OFF_ON_ON, N_BUTTON) == 0){ // ジンバー if(memcmp(state, OFF_OFF_OFF, N_BUTTON) == 0){ action = ROCKSEED_RELEASE; mp3_play(action); led_counter = 0; flag_clear(); }else if(memcmp(state, ON_OFF_OFF, N_BUTTON) == 0){ ; }else if(memcmp(state, OFF_ON_OFF, N_BUTTON) == 0){ action = ROCKSEED_RELEASE; mp3_play(action); led_counter = 0; flag_clear(); }else if(memcmp(state, ON_ON_OFF, N_BUTTON) == 0){ ; }else if(memcmp(state, OFF_OFF_ON, N_BUTTON) == 0){ action = ROCKSEED_RELEASE; mp3_play(action); led_counter = 0; flag_clear(); }else if(memcmp(state, ON_OFF_ON, N_BUTTON) == 0){ ; }else if(memcmp(state, OFF_ON_ON, N_BUTTON) == 0){ ; }else if(memcmp(state, ON_ON_ON, N_BUTTON) == 0){ switch(transform_flag){ // 変身・必殺処理 case false: action = JIMBAR; mp3_play(action); led_counter = 0; transform_flag = !transform_flag; transform_time = millis(); break; case true: unsigned long now = millis(); if(now - transform_time >= 14500){ if(special_ID == 0){ // special_IDが0 action = JIMBAR_SQUASH; mp3_play(action); led_counter = 0; special_ID++; special_time = now; }else if(special_ID == 1 && now - special_time <= 1000){ // special_IDが1かつ前回入力より1秒以内 action = JIMBAR_AU_LAIT; mp3_play(action); led_counter = 0; special_ID++; special_time = now; }else if(special_ID == 2 && now - special_time <= 1000){ // special_IDが2かつ前回入力より1秒以内 action = JIMBAR_SPARKING; mp3_play(action); led_counter = 0; special_time = now; }else{ action = JIMBAR_SQUASH; mp3_play(action); led_counter = 0; special_ID = 1; special_time = now; } } break; } } }else if(memcmp(before_state, ON_ON_ON, N_BUTTON) == 0){ if(memcmp(state, OFF_OFF_OFF, N_BUTTON) == 0){ action = ROCKSEED_RELEASE; mp3_play(action); led_counter = 0; flag_clear(); }else if(memcmp(state, ON_OFF_OFF, N_BUTTON) == 0){ ; }else if(memcmp(state, OFF_ON_OFF, N_BUTTON) == 0){ ; }else if(memcmp(state, ON_ON_OFF, N_BUTTON) == 0){ ; }else if(memcmp(state, OFF_OFF_ON, N_BUTTON) == 0){ ; }else if(memcmp(state, ON_OFF_ON, N_BUTTON) == 0){ ; }else if(memcmp(state, OFF_ON_ON, N_BUTTON) == 0){ ; }else if(memcmp(state, ON_ON_ON, N_BUTTON) == 0){ ; } } flash_led(); before_sw1 = sw1; before_state[0] = state[0]; before_state[1] = state[1]; before_state[2] = state[2]; before_action = action; delay(LOOP_INTERVAL_MS); }
さて、Twitterでもつぶやきましたが、次回は8年前のリベンジ。オリジナルガイアメモリ作製にとりかかろうと思います。
0 件のコメント:
コメントを投稿