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:
Sat Apr 04 23:51:19 2020 +0000
Parent:
4:1790aa9234a3
Child:
20:8c3644bf5d28
Commit message:
refactoring and servo testing

Changed in this revision

Servo.lib Show annotated file Show diff for this revision Revisions of this file
audio_out.h 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
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	Sat Apr 04 23:51:19 2020 +0000
@@ -0,0 +1,1 @@
+http://mbed.org/users/simon/code/Servo/#36b69a7ced07
--- a/audio_out.h	Tue Mar 31 20:03:55 2020 +0000
+++ b/audio_out.h	Sat Apr 04 23:51:19 2020 +0000
@@ -12,7 +12,7 @@
 uint32_t distance;
 
 bool state = false;
-Speaker mySpeaker(p22);
+Speaker mySpeaker(p25);
 double freq [30];
 
 double *record(double freq1[30]) 
--- a/main.cpp	Tue Mar 31 20:03:55 2020 +0000
+++ b/main.cpp	Sat Apr 04 23:51:19 2020 +0000
@@ -1,5 +1,6 @@
 #include "mbed.h"
 #include "audio_out.h"
+#include "motor_ctl.h"
 
 DigitalOut myled(LED1);
 // States 
@@ -106,5 +107,7 @@
 }
 
 int main() {
-    state_machine_mgr();
+    //state_machine_mgr();
+    //motor_ctl();
+    record_and_play();
 }
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/motor_ctl.h	Sat Apr 04 23:51:19 2020 +0000
@@ -0,0 +1,52 @@
+/*// Hello World to sweep a servo through its full range
+
+#include "mbed.h"
+#include "Servo.h"
+#include "rtos.h"
+
+Servo r_arm(p18);
+Servo l_arm(p19);
+//Servo r_leg(p20);
+//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 r_dance() {    
+    r_arm = 0; 
+    for(int i = 0; i < 10; ++i) {
+        r_arm = r_dists[i]/20;
+        wait(0.2);
+    }
+}
+
+void l_dance() {    
+    l_arm = 0; 
+    for(int i = 0; i < 10; ++i) {
+        l_arm = l_dists[i]/20;
+        wait(0.2);
+    }
+}
+
+
+void motor_ctl(){
+    t_r_arm.start(r_dance);
+    t_l_arm.start(l_dance);
+}
+
+*/