NHK2021_ikarashiSolenoidValve
Dependents: NHK2021_ikarashiSV_code NHK2021_ikarashiSV_code_withservo 2021NHK_B_syudo
ikarashiSV.h@0:2b253298d427, 2021-10-11 (annotated)
- Committer:
- ikarashikota
- Date:
- Mon Oct 11 07:48:12 2021 +0000
- Revision:
- 0:2b253298d427
- Child:
- 1:696f7c0ab1bd
NHK2021_ikarashiSolenoidValve
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
ikarashikota | 0:2b253298d427 | 1 | /** @ikarashiSV.h |
ikarashikota | 0:2b253298d427 | 2 | * |
ikarashikota | 0:2b253298d427 | 3 | * NHK2021Bチーム 電磁弁のライブラリです |
ikarashikota | 0:2b253298d427 | 4 | * @attention 回路が悪いのか電磁弁が悪いのかわかりませんが、訳あってpin_c,pin_dの代入値を本来とは逆にしています。 |
ikarashikota | 0:2b253298d427 | 5 | */ |
ikarashikota | 0:2b253298d427 | 6 | #ifndef ikarashi_SOLENOID |
ikarashikota | 0:2b253298d427 | 7 | #define ikarashi_SOLENOID |
ikarashikota | 0:2b253298d427 | 8 | |
ikarashikota | 0:2b253298d427 | 9 | #include "mbed.h" |
ikarashikota | 0:2b253298d427 | 10 | |
ikarashikota | 0:2b253298d427 | 11 | /** ikrashiSV |
ikarashikota | 0:2b253298d427 | 12 | * |
ikarashikota | 0:2b253298d427 | 13 | * 電磁弁が動かせます |
ikarashikota | 0:2b253298d427 | 14 | */ |
ikarashikota | 0:2b253298d427 | 15 | class ikarashiSV |
ikarashikota | 0:2b253298d427 | 16 | { |
ikarashikota | 0:2b253298d427 | 17 | public: |
ikarashikota | 0:2b253298d427 | 18 | |
ikarashikota | 0:2b253298d427 | 19 | /** コンストラクタ |
ikarashikota | 0:2b253298d427 | 20 | * |
ikarashikota | 0:2b253298d427 | 21 | * @param pin_a 下の電磁弁 |
ikarashikota | 0:2b253298d427 | 22 | * @param pin_b ↑同じ |
ikarashikota | 0:2b253298d427 | 23 | * |
ikarashikota | 0:2b253298d427 | 24 | * @param pin_c 上の電磁弁 |
ikarashikota | 0:2b253298d427 | 25 | * @param pin_d ↑同じ |
ikarashikota | 0:2b253298d427 | 26 | */ |
ikarashikota | 0:2b253298d427 | 27 | ikarashiSV(PinName pin_a,PinName pin_b,PinName pin_c,PinName pin_d); |
ikarashikota | 0:2b253298d427 | 28 | |
ikarashikota | 0:2b253298d427 | 29 | /** 使っても使わなくてもいいやつ |
ikarashikota | 0:2b253298d427 | 30 | * |
ikarashikota | 0:2b253298d427 | 31 | * state って言いう変数に+1します(state初期値0) |
ikarashikota | 0:2b253298d427 | 32 | */ |
ikarashikota | 0:2b253298d427 | 33 | void add_state(); |
ikarashikota | 0:2b253298d427 | 34 | |
ikarashikota | 0:2b253298d427 | 35 | /** 大本命関数 |
ikarashikota | 0:2b253298d427 | 36 | * |
ikarashikota | 0:2b253298d427 | 37 | * _state = 1 ・・・ 下の電磁弁が押す |
ikarashikota | 0:2b253298d427 | 38 | * _state = 2 ・・・ 上の電磁弁が押す(投げる) |
ikarashikota | 0:2b253298d427 | 39 | * _state = 0 ・・・ 元に戻る |
ikarashikota | 0:2b253298d427 | 40 | * @param _state 条件分岐用変数 |
ikarashikota | 0:2b253298d427 | 41 | */ |
ikarashikota | 0:2b253298d427 | 42 | void solenoid(int _state); |
ikarashikota | 0:2b253298d427 | 43 | |
ikarashikota | 0:2b253298d427 | 44 | /** 電磁弁の状態を確認する関数 |
ikarashikota | 0:2b253298d427 | 45 | * 押していたらpushで、引いていたらpullです |
ikarashikota | 0:2b253298d427 | 46 | */ |
ikarashikota | 0:2b253298d427 | 47 | void solenoid_show(); |
ikarashikota | 0:2b253298d427 | 48 | |
ikarashikota | 0:2b253298d427 | 49 | /** 使わなくてもいい(n回目) |
ikarashikota | 0:2b253298d427 | 50 | * |
ikarashikota | 0:2b253298d427 | 51 | * @return state を返します |
ikarashikota | 0:2b253298d427 | 52 | */ |
ikarashikota | 0:2b253298d427 | 53 | int state_show(); |
ikarashikota | 0:2b253298d427 | 54 | private: |
ikarashikota | 0:2b253298d427 | 55 | int state; |
ikarashikota | 0:2b253298d427 | 56 | int _state; |
ikarashikota | 0:2b253298d427 | 57 | int solenoid_status; |
ikarashikota | 0:2b253298d427 | 58 | DigitalOut port_a;//1 下の電磁弁 |
ikarashikota | 0:2b253298d427 | 59 | DigitalOut port_b;// |
ikarashikota | 0:2b253298d427 | 60 | |
ikarashikota | 0:2b253298d427 | 61 | DigitalOut port_c;//2 上の電磁弁 |
ikarashikota | 0:2b253298d427 | 62 | DigitalOut port_d;// |
ikarashikota | 0:2b253298d427 | 63 | }; |
ikarashikota | 0:2b253298d427 | 64 | |
ikarashikota | 0:2b253298d427 | 65 | #endif |