ビーンバック回収、テープLED、美少女ボイス担当マイコンのプログラム
Dependencies: mbed SBDBT arrc_mbed play_mp3
Diff: main.cpp
- Revision:
- 2:9adbf7e03f35
- Parent:
- 1:677d12692be0
- Child:
- 3:4d2a0e4bb4d9
diff -r 677d12692be0 -r 9adbf7e03f35 main.cpp --- a/main.cpp Thu Feb 03 13:20:16 2022 +0000 +++ b/main.cpp Sat Feb 05 11:27:14 2022 +0000 @@ -5,12 +5,11 @@ Serial pc(USBTX,USBRX); ScrpSlave slave(PC_12,PD_2,PH_1,SERIAL_TX,SERIAL_RX,5); NeoPixelOut npx(PB_0,10); -//モード変更 50 非常停止 51 bool colormode = 0; bool stop = 0; int i = 0; -int j = 0; +//モード変更 50 bool get_changemode(int rx_data,int &tx_data) { if(colormode == 0) { @@ -21,6 +20,7 @@ return 0; } +//非常停止 51 bool get_stop(int rx_data,int &tx_data) { if(stop == 0) { @@ -36,35 +36,41 @@ int main() { + //モード変更 slave.addCMD(50,get_changemode); + //非常停止 slave.addCMD(51,get_stop); + //光の強さ npx.global_scale = 0.05f; + //信号来ていないときは光らない npx.normalize = false; while(1) { + //非常停止解除 if(stop == 0) { + //手動モード 赤 if(colormode == 0) { for(i = 0; i < npx.numPixels(); i++) { npx.setPixelColor(i,0xFF0000); npx.show(); pc.printf("control\n"); wait(0.05); - //npx.setPixelColor(i,0x000000); if(i == npx.numPixels()) { i = 0; } } + //自動モード 青 } else if(colormode == 1) { for(i = 0; i < npx.numPixels(); i++) { npx.setPixelColor(i,0x0000FF); npx.show(); pc.printf("auto\n"); wait(0.05); - //npx.setPixelColor(i,0x000000); if(i == npx.numPixels()) { i = 0; } } } + //非常停止 } else if(stop == 1) { for(i = 0; i < npx.numPixels(); i++) { pc.printf("stopping\n");