This program is about limit switches11_18version.
Dependencies: mbed
main.cpp
- Committer:
- shina
- Date:
- 2019-06-25
- Revision:
- 1:08c96d55206d
- Parent:
- 0:28ee674a717f
- Child:
- 2:f64f79a6b5e0
File content as of revision 1:08c96d55206d:
///////////////////////////////////// /*NHK2019*/ /*Aチーム手動機リミットスイッチ用プログラム*/ //////////////////////////////////// #include "mbed.h" Serial master(PC_6,PC_7); Serial pc(USBTX,USBRX); DigitalIn limit1(D9);//右上ラック DigitalIn limit2(D8);//左上ラック DigitalIn limit3(D7);//右下ラック DigitalIn limit4(D6);//左下ラック DigitalIn limit5(D5);//回収機構右 DigitalIn limit6(D4);//回収機構左 DigitalIn limit7(D2);//予備 DigitalOut green(D12);//電源確認 DigitalOut yellow(D11);//通信確認 DigitalOut red(D10);//動作確認 //データ格納用変数 char data; //関数プロトタイプ宣言 void send_data(char send); //main()関数 int main(){ green=1; limit1.mode(PullUp); limit2.mode(PullUp); limit3.mode(PullUp); limit4.mode(PullUp); limit5.mode(PullUp); limit6.mode(PullUp); limit7.mode(PullUp); while(true){ if(!limit1&&!limit2){ red=1; data=0x20; send_data(data); }else if(!limit1&&limit2){ red=1; data=0x22; send_data(data); }else if(limit1&&!limit2){ red=1; data=0x24; send_data(data); }else if(!limit3&&!limit4){ red=1; data=0x26; send_data(data); }else if(!limit3&&limit4){ red=1; data=0x28; send_data(data); }else if(limit3&&!limit4){ red=1; data=0x30; send_data(data); }else if(!limit5){ red=1; data=0x32; send_data(data); }else if(!limit6){ red=1; data=0x34; send_data(data); }else if(!limit7){ red=1; data=0x36; send_data(data); }else{ red=0; data=0x38; send_data(data); } } } //rs232通信 void send_data(char send){ yellow=1; master.putc(send); wait(0.005); }