ECE3872 HW/SW Project Code
Dependencies: mbed Servo mbed-rtos 4DGL-uLCD-SE PinDetect X_NUCLEO_53L0A1
motor_ctl.h@24:930fc58e927a, 2020-04-11 (annotated)
- Committer:
- trmontgomery
- Date:
- Sat Apr 11 20:56:21 2020 +0000
- Revision:
- 24:930fc58e927a
re-added motor_ctl.h
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
trmontgomery | 24:930fc58e927a | 1 | /*// Hello World to sweep a servo through its full range |
trmontgomery | 24:930fc58e927a | 2 | |
trmontgomery | 24:930fc58e927a | 3 | #include "mbed.h" |
trmontgomery | 24:930fc58e927a | 4 | #include "Servo.h" |
trmontgomery | 24:930fc58e927a | 5 | #include "rtos.h" |
trmontgomery | 24:930fc58e927a | 6 | |
trmontgomery | 24:930fc58e927a | 7 | Servo r_arm(p18); |
trmontgomery | 24:930fc58e927a | 8 | Servo l_arm(p19); |
trmontgomery | 24:930fc58e927a | 9 | //Servo r_leg(p20); |
trmontgomery | 24:930fc58e927a | 10 | //Servo l_leg(p21); |
trmontgomery | 24:930fc58e927a | 11 | |
trmontgomery | 24:930fc58e927a | 12 | Thread t_r_arm; |
trmontgomery | 24:930fc58e927a | 13 | Thread t_l_arm; |
trmontgomery | 24:930fc58e927a | 14 | //Thread t_r_leg; |
trmontgomery | 24:930fc58e927a | 15 | //Thread t_l_leg; |
trmontgomery | 24:930fc58e927a | 16 | |
trmontgomery | 24:930fc58e927a | 17 | DigitalOut led(LED4); |
trmontgomery | 24:930fc58e927a | 18 | |
trmontgomery | 24:930fc58e927a | 19 | //left sensor move whole left side |
trmontgomery | 24:930fc58e927a | 20 | //right sensor moves whole right side //not gonna think about this right now. Dicuss ideas with team. |
trmontgomery | 24:930fc58e927a | 21 | //and then the distance can just control the height |
trmontgomery | 24:930fc58e927a | 22 | //movement pattern can be random.. right now every other note recorded will be distributed to one side and the rest will go to the other |
trmontgomery | 24:930fc58e927a | 23 | |
trmontgomery | 24:930fc58e927a | 24 | |
trmontgomery | 24:930fc58e927a | 25 | float dists[] = {1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20}; //should I lock this or just make new arrs? |
trmontgomery | 24:930fc58e927a | 26 | float r_dists[] = {1,3,5,7,9,11,13,15,17,19}; |
trmontgomery | 24:930fc58e927a | 27 | float l_dists[] = {2,4,6,8,10,12,14,16,18,20}; |
trmontgomery | 24:930fc58e927a | 28 | |
trmontgomery | 24:930fc58e927a | 29 | |
trmontgomery | 24:930fc58e927a | 30 | void r_dance() { |
trmontgomery | 24:930fc58e927a | 31 | r_arm = 0; |
trmontgomery | 24:930fc58e927a | 32 | for(int i = 0; i < 10; ++i) { |
trmontgomery | 24:930fc58e927a | 33 | r_arm = r_dists[i]/20; |
trmontgomery | 24:930fc58e927a | 34 | wait(0.2); |
trmontgomery | 24:930fc58e927a | 35 | } |
trmontgomery | 24:930fc58e927a | 36 | } |
trmontgomery | 24:930fc58e927a | 37 | |
trmontgomery | 24:930fc58e927a | 38 | void l_dance() { |
trmontgomery | 24:930fc58e927a | 39 | l_arm = 0; |
trmontgomery | 24:930fc58e927a | 40 | for(int i = 0; i < 10; ++i) { |
trmontgomery | 24:930fc58e927a | 41 | l_arm = l_dists[i]/20; |
trmontgomery | 24:930fc58e927a | 42 | wait(0.2); |
trmontgomery | 24:930fc58e927a | 43 | } |
trmontgomery | 24:930fc58e927a | 44 | } |
trmontgomery | 24:930fc58e927a | 45 | |
trmontgomery | 24:930fc58e927a | 46 | |
trmontgomery | 24:930fc58e927a | 47 | void motor_ctl(){ |
trmontgomery | 24:930fc58e927a | 48 | t_r_arm.start(r_dance); |
trmontgomery | 24:930fc58e927a | 49 | t_l_arm.start(l_dance); |
trmontgomery | 24:930fc58e927a | 50 | } |
trmontgomery | 24:930fc58e927a | 51 | |
trmontgomery | 24:930fc58e927a | 52 | */ |