NHK2021_ikarashiSolenoidValve
Dependents: NHK2021_ikarashiSV_code NHK2021_ikarashiSV_code_withservo 2021NHK_B_syudo
Diff: ikarashiSV.cpp
- Revision:
- 7:58da8ee2b38d
- Parent:
- 6:256162828e87
- Child:
- 8:f276fe03c43d
diff -r 256162828e87 -r 58da8ee2b38d ikarashiSV.cpp --- a/ikarashiSV.cpp Fri Oct 22 06:36:52 2021 +0000 +++ b/ikarashiSV.cpp Fri Oct 22 07:59:13 2021 +0000 @@ -43,13 +43,13 @@ { switch(solenoid_status) { case 1: - printf("1:push\n\r"); + printf("1:push"); break; case 2: - printf("1:pull\n\r"); + printf("1:pull"); break; case 0: - printf("1:open\n\r"); + printf("1:open"); break; } } @@ -59,6 +59,38 @@ return state; } + +ikarashiSV2::ikarashiSV2(PinName pin_e, PinName pin_f): + port_e(pin_e),port_f(pin_f) +{ + solenoid_status2 = 0; +} + +void ikarashiSV2::solenoid(int _state2) +{ + switch(_state2) { + case 1: + port_e = 0; + port_f = 1; + solenoid_status2 = 1; + break; + case 0; + port_e = 1; + port_f = 0; + solenoid_status2 = 0; + break; + } +} + +void ikarashiSV2::solenoid_show() +{ + if(solenoid_status2) { + printf("2:push"); + } else { + printf("2:pull"); + } +} + /* サンプルコード #include "mbed.h"