NHK2017 octopus robot
Dependencies: 2017NHKpin_config mbed FEP ikarashiMDC PID jy901 omni HMC6352 omni_wheel
Fork of KANI2017v2 by
Diff: bot/limitSwitch/limitSwitch.cpp
- Revision:
- 23:37bb9afe9fdc
- Child:
- 25:d199d621ecca
diff -r 682cc376da6f -r 37bb9afe9fdc bot/limitSwitch/limitSwitch.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/bot/limitSwitch/limitSwitch.cpp Wed Sep 13 14:26:47 2017 +0900 @@ -0,0 +1,29 @@ +#include "limitSwitch.h" + +Limit::Limit(PinName limitSwitch1, PinName limitSwitch2) : frontSwitch(limitSwitch1), backSwitch(limitSwitch2) +{ + + frontSwitch.rise(callback(this, &Limit::frontLimit)); + backSwitch.rise(callback(this, &Limit::backLimit)); + +} + +void Limit::frontLimit() +{ + position = 1; +} + +void Limit::backLimit() +{ + position = -1; +} + +void Limit::resetPosition() +{ + position = 0; +} + +int Limit::getPosition() +{ + return position; +}