Rianne Bulthuis
/
encoder_and_HIDscope
Movement, encoder and HIDscope
Revision 0:f69c13e72486, committed 2015-10-13
- Comitter:
- riannebulthuis
- Date:
- Tue Oct 13 20:12:01 2015 +0000
- Commit message:
- benaming en beschrijving bijgevoegd;
Changed in this revision
main.cpp | Show annotated file Show diff for this revision Revisions of this file |
mbed.bld | Show annotated file Show diff for this revision Revisions of this file |
diff -r 000000000000 -r f69c13e72486 main.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/main.cpp Tue Oct 13 20:12:01 2015 +0000 @@ -0,0 +1,58 @@ +#include "mbed.h" +#include "HIDScope.h" +#include "encoder.h" + + +//pinverdeling en naamgeving variabelen +Encoder motor1(D13,D12); // telt pulsen bij verdraaiing en zet dit om in de rotatiehoek +PwmOut led(D9); +DigitalOut motor_direction(D4); // motor direction +PwmOut motor_speed(D5); // motor speed +DigitalIn button_1(PTC6); // counterclockwise +DigitalIn button_2(PTA4); // clockwise +HIDScope scope(1); // Hidscope op channel 1??!! + +const int pressed = 0; //signaal(beweging) bij indrukken + +void move_motor_ccw () //beweging ccw motor 1, signaal van linker biceps +{ + motor_direction = 0; + motor_speed = 1; +} + +void move_motor_cw () // beweging cw motor 1, signaal van rechter biceps +{ + motor_direction = 1; + motor_speed = 0.1; +} + +void read_encoder () // aflezen van encoder via hidscope?? +{ + scope.set(0,motor1.getPosition()); + led.write(motor1.getPosition()/100.0); + scope.send(); + wait(0.2f); +} + +void move() // beweging van motor 1 cw of ccw d.m.v. button 1 of 2 +{ + if (button_1 == pressed) { + move_motor_cw (); + } else if (button_2 == pressed) { + move_motor_ccw (); + } else { + motor_speed = 0; + } +} + +//uitvoeren van script +int main() +{ + while (true) { + + read_encoder(); + move(); + } + +} +
diff -r 000000000000 -r f69c13e72486 mbed.bld --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/mbed.bld Tue Oct 13 20:12:01 2015 +0000 @@ -0,0 +1,1 @@ +http://mbed.org/users/mbed_official/code/mbed/builds/34e6b704fe68 \ No newline at end of file