ビーンバック回収、テープLED、美少女ボイス担当マイコンのプログラム
Dependencies: mbed SBDBT arrc_mbed play_mp3
main.cpp
- Committer:
- sopuranoaruto
- Date:
- 2022-02-03
- Revision:
- 1:677d12692be0
- Parent:
- 0:12a2f5f9ab60
- Child:
- 2:9adbf7e03f35
File content as of revision 1:677d12692be0:
#include "mbed.h" #include "neopixel.h" #include "scrp_slave.hpp" 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; bool get_changemode(int rx_data,int &tx_data) { if(colormode == 0) { colormode = 1; } else { colormode = 0; } return 0; } bool get_stop(int rx_data,int &tx_data) { if(stop == 0) { stop = 1; for(i=0; i<npx.numPixels(); i++) { npx.setPixelColor(i,0x000000); } } else { stop = 0; } return 0; } 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"); npx.setPixelColor(i,0x000000); npx.show(); wait(0.05); if(i == npx.numPixels()) { i = 0; } } } } }