![](/media/cache/group/default_image.jpg.50x50_q85.jpg)
offline compile base
Dependencies: mbed SDFileSystem MU2 GPS
inletclose/inletclose.h@0:301e9f8aafb4, 2019-08-21 (annotated)
- Committer:
- takepiyo
- Date:
- Wed Aug 21 02:10:00 2019 +0000
- Revision:
- 0:301e9f8aafb4
offline compile base
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
takepiyo | 0:301e9f8aafb4 | 1 | #include "mbed.h" |
takepiyo | 0:301e9f8aafb4 | 2 | |
takepiyo | 0:301e9f8aafb4 | 3 | #ifndef InletClose_H |
takepiyo | 0:301e9f8aafb4 | 4 | #define InletClose_H |
takepiyo | 0:301e9f8aafb4 | 5 | |
takepiyo | 0:301e9f8aafb4 | 6 | class Inlet |
takepiyo | 0:301e9f8aafb4 | 7 | { |
takepiyo | 0:301e9f8aafb4 | 8 | private: |
takepiyo | 0:301e9f8aafb4 | 9 | DigitalOut _Out;//モータ用 1で回転,0で停止 |
takepiyo | 0:301e9f8aafb4 | 10 | |
takepiyo | 0:301e9f8aafb4 | 11 | AnalogIn _In1; |
takepiyo | 0:301e9f8aafb4 | 12 | AnalogIn _In2;//感圧センサーとつなぐピン |
takepiyo | 0:301e9f8aafb4 | 13 | |
takepiyo | 0:301e9f8aafb4 | 14 | float value1;//感圧センサーの値をいれる |
takepiyo | 0:301e9f8aafb4 | 15 | float value2; |
takepiyo | 0:301e9f8aafb4 | 16 | |
takepiyo | 0:301e9f8aafb4 | 17 | public: |
takepiyo | 0:301e9f8aafb4 | 18 | |
takepiyo | 0:301e9f8aafb4 | 19 | Inlet(PinName Out,PinName In1,PinName In2) |
takepiyo | 0:301e9f8aafb4 | 20 | :_Out(Out),_In1(In1),_In2(In2){} |
takepiyo | 0:301e9f8aafb4 | 21 | |
takepiyo | 0:301e9f8aafb4 | 22 | |
takepiyo | 0:301e9f8aafb4 | 23 | void Close(float judge)//センサのどっちかがjudgeを超えるとモーターは停止 |
takepiyo | 0:301e9f8aafb4 | 24 | { |
takepiyo | 0:301e9f8aafb4 | 25 | _Out=1; |
takepiyo | 0:301e9f8aafb4 | 26 | |
takepiyo | 0:301e9f8aafb4 | 27 | if(getvalue1()>judge | getvalue2()>judge) |
takepiyo | 0:301e9f8aafb4 | 28 | { |
takepiyo | 0:301e9f8aafb4 | 29 | _Out=0; |
takepiyo | 0:301e9f8aafb4 | 30 | } |
takepiyo | 0:301e9f8aafb4 | 31 | } |
takepiyo | 0:301e9f8aafb4 | 32 | |
takepiyo | 0:301e9f8aafb4 | 33 | void Stop() |
takepiyo | 0:301e9f8aafb4 | 34 | { |
takepiyo | 0:301e9f8aafb4 | 35 | _Out=0; |
takepiyo | 0:301e9f8aafb4 | 36 | } |
takepiyo | 0:301e9f8aafb4 | 37 | |
takepiyo | 0:301e9f8aafb4 | 38 | float getvalue1() |
takepiyo | 0:301e9f8aafb4 | 39 | { |
takepiyo | 0:301e9f8aafb4 | 40 | value1=_In1.read(); |
takepiyo | 0:301e9f8aafb4 | 41 | return value1; |
takepiyo | 0:301e9f8aafb4 | 42 | } |
takepiyo | 0:301e9f8aafb4 | 43 | |
takepiyo | 0:301e9f8aafb4 | 44 | float getvalue2() |
takepiyo | 0:301e9f8aafb4 | 45 | { |
takepiyo | 0:301e9f8aafb4 | 46 | value2=_In2.read(); |
takepiyo | 0:301e9f8aafb4 | 47 | return value2; |
takepiyo | 0:301e9f8aafb4 | 48 | } |
takepiyo | 0:301e9f8aafb4 | 49 | |
takepiyo | 0:301e9f8aafb4 | 50 | |
takepiyo | 0:301e9f8aafb4 | 51 | }; |
takepiyo | 0:301e9f8aafb4 | 52 | |
takepiyo | 0:301e9f8aafb4 | 53 | #endif |