servo motor werkt eindelijk!!!! wiehoe!!!
Dependencies: mbed QEI Servo HIDScope biquadFilter MODSERIAL FastPWM
main.cpp@4:d3e8ec68ff97, 2019-10-29 (annotated)
- Committer:
- IsaRobin
- Date:
- Tue Oct 29 20:58:26 2019 +0000
- Revision:
- 4:d3e8ec68ff97
- Parent:
- 3:f30c2ded1a58
- Child:
- 5:e21d303d62d8
final versie van dinsdag avond voor de servo motor;
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
IsaRobin | 4:d3e8ec68ff97 | 1 | /* servo motor program - biorbotics group 8 */ |
jasperkessels | 0:009a005982e5 | 2 | |
jasperkessels | 0:009a005982e5 | 3 | #include <Servo.h> |
jasperkessels | 0:009a005982e5 | 4 | #include <mbed.h> |
jasperkessels | 0:009a005982e5 | 5 | #include <math.h> /* cos */ |
jasperkessels | 0:009a005982e5 | 6 | #include <MODSERIAL.h> |
jasperkessels | 0:009a005982e5 | 7 | |
IsaRobin | 4:d3e8ec68ff97 | 8 | MODSERIAL pc(USBTX, USBRX); //connect pc |
IsaRobin | 4:d3e8ec68ff97 | 9 | Servo myservo(D3); //the servo motor is connected to pin D3 on the BioRobotics shield |
IsaRobin | 3:f30c2ded1a58 | 10 | |
IsaRobin | 4:d3e8ec68ff97 | 11 | //Buttons that will be used to control the servo motor |
IsaRobin | 4:d3e8ec68ff97 | 12 | InterruptIn button2(SW2); //when this button is pushed, the servo motor rotates 90 degrees counterclockwise |
IsaRobin | 4:d3e8ec68ff97 | 13 | InterruptIn button3(SW3); //when this button is pushed, the servo motor rotates 90 degrees clockclockwise |
IsaRobin | 1:1b33fd02e6b1 | 14 | |
IsaRobin | 4:d3e8ec68ff97 | 15 | void showcard() |
IsaRobin | 3:f30c2ded1a58 | 16 | { |
jasperkessels | 0:009a005982e5 | 17 | |
IsaRobin | 3:f30c2ded1a58 | 18 | myservo.SetPosition(2000); |
IsaRobin | 4:d3e8ec68ff97 | 19 | pc.printf("card is being showed to user.\n.\r"); |
IsaRobin | 3:f30c2ded1a58 | 20 | |
IsaRobin | 3:f30c2ded1a58 | 21 | } |
IsaRobin | 3:f30c2ded1a58 | 22 | |
IsaRobin | 4:d3e8ec68ff97 | 23 | void hidecard() |
IsaRobin | 3:f30c2ded1a58 | 24 | { |
IsaRobin | 3:f30c2ded1a58 | 25 | myservo.SetPosition(1000); |
IsaRobin | 4:d3e8ec68ff97 | 26 | pc.printf("card is being rotated away from user .\n.\r"); |
IsaRobin | 3:f30c2ded1a58 | 27 | |
IsaRobin | 3:f30c2ded1a58 | 28 | } |
jasperkessels | 0:009a005982e5 | 29 | |
jasperkessels | 0:009a005982e5 | 30 | int main() |
jasperkessels | 0:009a005982e5 | 31 | { |
IsaRobin | 1:1b33fd02e6b1 | 32 | pc.baud(115200); |
IsaRobin | 1:1b33fd02e6b1 | 33 | pc.printf("starting main .\r.\n"); |
IsaRobin | 3:f30c2ded1a58 | 34 | myservo.Enable(1000,20000); |
IsaRobin | 3:f30c2ded1a58 | 35 | |
IsaRobin | 4:d3e8ec68ff97 | 36 | button2.rise(showcard); |
IsaRobin | 4:d3e8ec68ff97 | 37 | button3.rise(hidecard); |
jasperkessels | 0:009a005982e5 | 38 | |
jasperkessels | 0:009a005982e5 | 39 | while(true) { |
IsaRobin | 4:d3e8ec68ff97 | 40 | pc.printf("weer begonnen aan mijn main"); //@Jasper hebben we deze nog echt nodgi |
IsaRobin | 3:f30c2ded1a58 | 41 | wait(2); |
IsaRobin | 3:f30c2ded1a58 | 42 | |
IsaRobin | 3:f30c2ded1a58 | 43 | } |
IsaRobin | 3:f30c2ded1a58 | 44 | } |
jasperkessels | 0:009a005982e5 | 45 | |
jasperkessels | 0:009a005982e5 | 46 | |
jasperkessels | 0:009a005982e5 | 47 | |
IsaRobin | 3:f30c2ded1a58 | 48 | |
IsaRobin | 4:d3e8ec68ff97 | 49 |