This program is about limit switches11_18version.
Dependencies: mbed
main.cpp
- Committer:
- shina
- Date:
- 2019-05-23
- Revision:
- 0:28ee674a717f
- Child:
- 1:08c96d55206d
File content as of revision 0:28ee674a717f:
#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); 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(!limit3||!limit4){ red=1; data=0x24; send_data(data); }else if(!limit5){ red=1; data=0x28; send_data(data); }else if(!limit6){ red=1; data=0x30; send_data(data); }else if(!limit7){ red=1; data=0x32; send_data(data); }else{ red=0; data=0x34; send_data(data); } } } void send_data(char send){ yellow=1; master.putc(send); wait(0.005); }