ECE3872 HW/SW Project Code

Dependencies:   mbed Servo mbed-rtos 4DGL-uLCD-SE PinDetect X_NUCLEO_53L0A1

Files at this revision

API Documentation at this revision

Comitter:
trmontgomery
Date:
Wed Apr 08 21:28:53 2020 +0000
Parent:
20:8c3644bf5d28
Child:
22:fd48dd707e4f
Commit message:
stuff

Changed in this revision

Servo.lib Show annotated file Show diff for this revision Revisions of this file
X_NUCLEO_53L0A1.lib Show annotated file Show diff for this revision Revisions of this file
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
motor_ctl.h Show annotated file Show diff for this revision Revisions of this file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/Servo.lib	Wed Apr 08 21:28:53 2020 +0000
@@ -0,0 +1,1 @@
+http://mbed.org/users/simon/code/Servo/#36b69a7ced07
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/X_NUCLEO_53L0A1.lib	Wed Apr 08 21:28:53 2020 +0000
@@ -0,0 +1,1 @@
+https://developer.mbed.org/teams/ST/code/X_NUCLEO_53L0A1/#27d3d95c8593
--- a/main.cpp	Sun Apr 05 05:36:12 2020 +0000
+++ b/main.cpp	Wed Apr 08 21:28:53 2020 +0000
@@ -3,12 +3,12 @@
 #include "audio_out.h"
 #include "PinDetect.h"
 #include "uLCD_4DGL.h"
+#include "motor_ctl.h"
 DigitalOut myled1(LED1);
 DigitalOut myled2(LED2);
 DigitalOut myled3(LED3);
 DigitalOut myled4(LED4);
-// LCD init
-uLCD_4DGL guLCD(p28, p27, p29); // serial tx, serial rx, reset pin;
+
 // Push buttons init
 PinDetect pb1(p16); 
 PinDetect pb2(p17);  
@@ -76,25 +76,25 @@
 void pb1_hit_callback (void) 
 {
     myled1 = !myled1; 
-    guLCD.printf("REEST");
+    //guLCD.printf("REEST");
 }
 
 void pb2_hit_callback (void)
 {
     myled2 = !myled2; 
-    guLCD.printf("STOP");
+    //guLCD.printf("STOP");
 }
 
 void pb3_hit_callback (void) 
 {
     myled3 = !myled3; 
-    guLCD.printf("RECORD");
+    //guLCD.printf("RECORD");
 }
 
 void pb4_hit_callback (void) 
 {
     myled4 = !myled4; 
-    guLCD.printf("PLAY");
+    //guLCD.printf("PLAY");
 }
 void hardware_init(){ 
     // Push buttons init
@@ -154,7 +154,10 @@
     }
 }
 
+
 int main() {
-    hardware_init();
-    state_machine_mgr();
+    myled1 = 1; 
+    //hardware_init();
+    //state_machine_mgr();
+    move_motors();
 }
--- a/mbed.bld	Sun Apr 05 05:36:12 2020 +0000
+++ b/mbed.bld	Wed Apr 08 21:28:53 2020 +0000
@@ -1,1 +1,1 @@
-https://os.mbed.com/users/mbed_official/code/mbed/builds/65be27845400
\ No newline at end of file
+https://os.mbed.com/users/mbed_official/code/mbed/builds/0ab6a29f35bf
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/motor_ctl.h	Wed Apr 08 21:28:53 2020 +0000
@@ -0,0 +1,88 @@
+// Hello World to sweep a servo through its full range
+
+#include "mbed.h"
+#include "Servo.h"
+#include "rtos.h"
+
+Servo r_arm(p24);
+Servo l_arm(p23);
+Servo r_leg(p22);
+Servo l_leg(p21);
+
+Thread t_r_arm;
+Thread t_l_arm;
+Thread t_r_leg;
+Thread t_l_leg;
+
+DigitalOut led(LED4); 
+
+//left sensor move whole left side
+//right sensor moves whole right side //not gonna think about this right now. Dicuss ideas with team. 
+//and then the distance can just control the height
+//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
+
+
+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?
+float r_dists[] = {1,3,5,7,9,11,13,15,17,19};
+float l_dists[] = {2,4,6,8,10,12,14,16,18,20};
+
+
+void ra_dance() {    
+    r_arm = 0; 
+    wait(1);
+    for(float p=0; p<1.0; p += 0.1) {
+        r_arm = p;
+        wait(0.2);
+    }
+    r_arm.write(.50);
+    
+}
+
+void la_dance() {    
+    l_arm = 0; 
+    wait(1);
+    for(float p=0; p<1.0; p += 0.1) {
+        l_arm = p;
+        wait(0.2);
+    }
+    l_arm.write(.50);
+    
+}
+
+void rl_dance() {    
+    r_leg = 0; 
+    wait(1);
+    for(float p=0; p<1.0; p += 0.1) {
+        r_leg = p;
+        wait(0.2);
+    }
+    r_leg.write(.50);
+    
+}
+
+void ll_dance() {    
+    l_leg = 0; 
+    wait(1);
+    for(float p=0; p<1.0; p += 0.1) {
+        l_leg = p;
+        wait(0.2);
+    }
+    l_leg.write(.50);
+    
+}
+
+
+void move_motors(){
+    while(1){
+    t_r_arm.start(ra_dance);
+    wait(1);
+    t_l_arm.start(la_dance);
+    wait(1);
+    t_r_leg.start(rl_dance);
+    wait(1);
+    t_l_leg.start(ll_dance);
+    wait(1);
+   }
+}
+
+