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