BrickUp API Service for Docker version.

TwoWheelSimple.cpp 2.0KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  1. /*
  2. Copyright (C) 2016 Wesley Tsai (wesleyboy42@gmail.com)
  3. Permission is hereby granted, free of charge, to any person obtaining a copy of
  4. this software and associated documentation files (the "Software"), to deal in
  5. the Software without restriction, including without limitation the rights to
  6. use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
  7. the Software, and to permit persons to whom the Software is furnished to do so,
  8. subject to the following conditions:
  9. The above copyright notice and this permission notice shall be included in all
  10. copies or substantial portions of the Software.
  11. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  12. IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
  13. FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
  14. COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
  15. IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
  16. CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
  17. */
  18. /*
  19. * Library for controlling two TT moto of DC 3v-12v.
  20. *
  21. * Information about the makercup obtained from:
  22. * https://medium.com/maker-cup
  23. */
  24. // --------------------------------------------------------------------------------------
  25. #include "TwoWheelSimple.h"
  26. // --------------------------------------------------------------------------------------
  27. TwoWheelSimple::TwoWheelSimple(byte MotoPinL, byte MotoPinR) :
  28. _MotoPinL(MotoPinL), _MotoPinR(MotoPinR)
  29. {
  30. }
  31. TwoWheelSimple::~TwoWheelSimple()
  32. {
  33. }
  34. // --------------------------------------------------------------------------------------
  35. void TwoWheelSimple::init()
  36. {
  37. pinMode(_MotoPinL, OUTPUT);
  38. pinMode(_MotoPinR, OUTPUT);
  39. }
  40. void TwoWheelSimple::forward(void)
  41. {
  42. digitalWrite(_MotoPinL, LOW);
  43. digitalWrite(_MotoPinR, HIGH);
  44. }
  45. void TwoWheelSimple::backward(void)
  46. {
  47. digitalWrite(_MotoPinL, HIGH);
  48. digitalWrite(_MotoPinR, LOW);
  49. }
  50. void TwoWheelSimple::stop(void)
  51. {
  52. digitalWrite(_MotoPinL, LOW);
  53. digitalWrite(_MotoPinR, LOW);
  54. }