Arun Raveenthiran
/
Movement
bewegen van motor bij indrukken van knopje
main.cpp
- Committer:
- arunr
- Date:
- 2015-10-13
- Revision:
- 0:037c49ea92e2
File content as of revision 0:037c49ea92e2:
#include "mbed.h" DigitalOut motor_direction(D4); PwmOut motor_speed(D5); DigitalIn button_1(PTC6); //counterclockwise DigitalIn button_2(PTA4); //clockwise const int pressed = 0; void move_motor_ccw (){ motor_direction = 0; motor_speed = 1; } void move_motor_cw (){ motor_direction = 1; motor_speed = 0.1; } int main() { while (true) { if (button_1 == pressed){ move_motor_cw (); } else if (button_2 == pressed){ move_motor_ccw (); } else { motor_speed = 0; } } }