NHK2021_ikarashiSolenoidValve
Dependents: NHK2021_ikarashiSV_code NHK2021_ikarashiSV_code_withservo 2021NHK_B_syudo
Revision 9:252dd0bc8f93, committed 2021-10-23
- Comitter:
- ikarashikota
- Date:
- Sat Oct 23 03:44:50 2021 +0000
- Parent:
- 8:f276fe03c43d
- Commit message:
- add doxygen
Changed in this revision
ikarashiSV.cpp | Show annotated file Show diff for this revision Revisions of this file |
ikarashiSV.h | Show annotated file Show diff for this revision Revisions of this file |
--- a/ikarashiSV.cpp Sat Oct 23 03:38:23 2021 +0000 +++ b/ikarashiSV.cpp Sat Oct 23 03:44:50 2021 +0000 @@ -69,12 +69,12 @@ void ikarashiSV2::solenoid(int _state2) { switch(_state2) { - case 1: + case 1://push port_e = 0; port_f = 1; solenoid_status2 = 1; break; - case 0: + case 0://pull port_e = 1; port_f = 0; solenoid_status2 = 0; @@ -96,29 +96,40 @@ #include "mbed.h" #include "ikarashiSV.h" +DigitalOut led1(LED1); Serial pc(USBTX, USBRX,115200); -ikarashiSV slv(PC_7,PB_10,PB_4,PB_5); +ikarashiSV slv1(PB_5,PB_4,PB_10,PA_5); +ikarashiSV2 slv2(PB_9,PB_8); +Servo servo(PB_14); +Ticker timer; //ボタンを押したときor離したときを読み取る定義の仕方 InterruptIn button(USER_BUTTON); +int check = 0; + void add() { - slv.add_state(); + if(check >= 1) { + slv1.add_state(); + } + check++; } int main() { int val; + timer.attach(&add, 2); while(1) { - button.fall(&add); - val = slv.state_show(); - pc.printf("\t\tstate : %d",val); - if(val >= 1) { - slv.solenoid(val%3); - } - slv.solenoid_show(); + val = slv1.state_show(); + pc.printf("state : %d",val); + pc.printf("\tservo : %0.2f\t",servo.read()); + slv1.solenoid_show(); + slv2.solenoid_show(); + printf("\n\r"); + slv1.solenoid(val%3); + slv2.solenoid(val%2); } }
--- a/ikarashiSV.h Sat Oct 23 03:38:23 2021 +0000 +++ b/ikarashiSV.h Sat Oct 23 03:44:50 2021 +0000 @@ -70,6 +70,11 @@ class ikarashiSV2{ public: ikarashiSV2(PinName pin_e, PinName pin_f); + + /** 大本命関数その2 + * _state2 = 1 ・・・ push + * _state2 = 0 ・・・ pull + */ void solenoid(int _state2); void solenoid_show(); private: