Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Dependencies: mbed mbedTimer SDFileSystem MU2 GPS
inletclose/inletclose.h@3:4f1bac105598, 2019-08-05 (annotated)
- Committer:
- takepiyo
- Date:
- Mon Aug 05 07:44:41 2019 +0000
- Revision:
- 3:4f1bac105598
- Child:
- 8:6b835a82b1eb
jazz;
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
takepiyo | 3:4f1bac105598 | 1 | #include "mbed.h" |
takepiyo | 3:4f1bac105598 | 2 | |
takepiyo | 3:4f1bac105598 | 3 | #ifndef InletClose_H |
takepiyo | 3:4f1bac105598 | 4 | #define InletClose_H |
takepiyo | 3:4f1bac105598 | 5 | |
takepiyo | 3:4f1bac105598 | 6 | class Inlet |
takepiyo | 3:4f1bac105598 | 7 | { |
takepiyo | 3:4f1bac105598 | 8 | private: |
takepiyo | 3:4f1bac105598 | 9 | DigitalOut _Out;//モータ用 1で回転,0で停止 |
takepiyo | 3:4f1bac105598 | 10 | |
takepiyo | 3:4f1bac105598 | 11 | AnalogIn _In1; |
takepiyo | 3:4f1bac105598 | 12 | AnalogIn _In2;//感圧センサーとつなぐピン |
takepiyo | 3:4f1bac105598 | 13 | |
takepiyo | 3:4f1bac105598 | 14 | float value1;//感圧センサーの値をいれる |
takepiyo | 3:4f1bac105598 | 15 | float value2; |
takepiyo | 3:4f1bac105598 | 16 | |
takepiyo | 3:4f1bac105598 | 17 | public: |
takepiyo | 3:4f1bac105598 | 18 | |
takepiyo | 3:4f1bac105598 | 19 | Inlet(PinName Out,PinName In1,PinName In2) |
takepiyo | 3:4f1bac105598 | 20 | :_Out(Out),_In1(In1),_In2(In2){} |
takepiyo | 3:4f1bac105598 | 21 | |
takepiyo | 3:4f1bac105598 | 22 | |
takepiyo | 3:4f1bac105598 | 23 | void Close(float judge)//センサのどっちかがjudgeを超えるとモーターは停止 |
takepiyo | 3:4f1bac105598 | 24 | { |
takepiyo | 3:4f1bac105598 | 25 | _Out=1; |
takepiyo | 3:4f1bac105598 | 26 | |
takepiyo | 3:4f1bac105598 | 27 | if(getvalue1()>judge | getvalue2()>judge) |
takepiyo | 3:4f1bac105598 | 28 | { |
takepiyo | 3:4f1bac105598 | 29 | _Out=0; |
takepiyo | 3:4f1bac105598 | 30 | } |
takepiyo | 3:4f1bac105598 | 31 | } |
takepiyo | 3:4f1bac105598 | 32 | |
takepiyo | 3:4f1bac105598 | 33 | float getvalue1() |
takepiyo | 3:4f1bac105598 | 34 | { |
takepiyo | 3:4f1bac105598 | 35 | value1=_In1.read(); |
takepiyo | 3:4f1bac105598 | 36 | return value1; |
takepiyo | 3:4f1bac105598 | 37 | } |
takepiyo | 3:4f1bac105598 | 38 | |
takepiyo | 3:4f1bac105598 | 39 | float getvalue2() |
takepiyo | 3:4f1bac105598 | 40 | { |
takepiyo | 3:4f1bac105598 | 41 | value2=_In2.read(); |
takepiyo | 3:4f1bac105598 | 42 | return value2; |
takepiyo | 3:4f1bac105598 | 43 | } |
takepiyo | 3:4f1bac105598 | 44 | |
takepiyo | 3:4f1bac105598 | 45 | |
takepiyo | 3:4f1bac105598 | 46 | }; |
takepiyo | 3:4f1bac105598 | 47 | |
takepiyo | 3:4f1bac105598 | 48 | #endif |