Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Revision 0:cf9c71a62530, committed 2018-10-22
- Comitter:
- evangeli
- Date:
- Mon Oct 22 13:43:24 2018 +0000
- Child:
- 1:b9ffc0aeb3ce
- Commit message:
- Initial commit
Changed in this revision
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/.gitignore Mon Oct 22 13:43:24 2018 +0000 @@ -0,0 +1,4 @@ +.build +.mbed +projectfiles +*.py*
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Motor.lib Mon Oct 22 13:43:24 2018 +0000 @@ -0,0 +1,1 @@ +https://os.mbed.com/users/simon/code/Motor/#a87ee6f7f3e6
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/README.md Mon Oct 22 13:43:24 2018 +0000 @@ -0,0 +1,2 @@ +# ES200 1121 Dolphin Club Sub Code +### MIDN 3/c Enger, Ewing, Hicks, Jordan
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Servo.lib Mon Oct 22 13:43:24 2018 +0000 @@ -0,0 +1,1 @@ +https://os.mbed.com/users/simon/code/Servo/#36b69a7ced07
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/main.cpp Mon Oct 22 13:43:24 2018 +0000
@@ -0,0 +1,147 @@
+/*
+ES200 1121 Project 2 Dolphin Club
+Run silent run deep.
+MIDN 3/c Enger, Ewing, Hicks, Jordan
+*/
+
+#include "mbed.h" // DE transitioned this to mbed OS 5 to do multitasking and threads
+#include "rtos.h"
+
+#include "stdio.h"
+#include "Motor.h"
+#include "Servo.h"
+
+// Global hardware objects
+Serial pc(USBTX,USBRX); // for talking back to computer
+
+// inputs
+DigitalIn prop_sw(p16); //switch to turn on the prop
+DigitalIn torpedo_sw(p17); //switch to fire the torpedo
+DigitalIn planes_sw(p18); //switch to tilt the fairwater planes
+DigitalIn lights_sw(p19); //switch to turn on the running lights
+
+// outputs
+DigitalOut green(p6); // external green LED
+DigitalOut red(p7); // external red LED
+Motor prop_motor(p26,p30,p29); //motor variable
+Servo torpedo_servo(p21); //torpedo servo
+Servo planes_servo(p22); //planes servo
+
+// other indicators
+DigitalOut heartbeat_led(LED1);
+DigitalOut prop_led(LED2);
+DigitalOut torpedo_led(LED3);
+DigitalOut planes_led(LED4);
+
+// do i need these???
+int screw;
+int fire;
+int fw;
+int running;
+
+// threads
+Thread prop_thread;
+Thread torpedo_thread;
+Thread planes_thread;
+Thread lights_thread;
+
+// callback function prototypes
+void prop_callback(void);
+void torpedo_callback(void);
+void planes_callback(void);
+void lights_callback(void);
+
+
+
+
+
+
+int main(void){ //main open
+ pc.printf("ES200 1121 Project 2 Team 2 Dolphin Club\r\n");
+ pc.printf("Submarines go deeper.\r\n");
+
+
+
+ while(1) { //while open
+// printf("reading switch positions\r\n");
+// screw = prop.read(); //reads switch for prop
+// fire = shoot.read(); //reads switch for torpedo
+// fw = planes.read(); //reads switch for planes
+// running = lights.read(); //reads switch for lights
+
+
+
+
+
+ if (fw == 1) { //switch 3 for planes
+ printf("planes\r\n");
+ tilt = 0.2;
+ wait(0.2);
+ tilt = 0.7;
+ wait(0.2);
+ }
+ else {
+ printf("no planes\r\n");
+ tilt = 0.0;
+ }
+ /*while(1) {
+ tilt = 0.2; //initial position
+ wait(0.7); //wait
+ tilt = 0.7; //tilted position
+ wait(0.7); //wait
+} //while close
+} //else if close
+ else if (fw==0) {
+ tilt = 0.2;
+ }
+ */
+
+
+ /* if (running== 1) { //switch 4 for lights to turn on
+ green = 1;
+ red = 1;
+ }
+ */
+ } //while close
+ } //main close
+
+
+
+
+
+void prop_callback(void)
+{
+ pc.printf("prop_thread standing by ready to answer bells on main engine\r\n");
+
+ while(1) {
+ if (prop_sw.read()) {
+ pc.printf("prop_thread all ahead flank\r\n");
+ prop_motor.speed(1.0);
+ } else {
+ pc.printf("prop_thread all stop\r\n");
+ prop_motor.speed(0.0);
+ }
+ } // while(1)
+} // prop_callback()
+
+
+
+void torpedo_callback(void)
+{
+ //if (fire == 1) { //switch 2 for torpeo firing
+ //printf("torpedo\r\n");
+ //}
+/* while(1) {
+ torpedo = 0.01; //start position inside body of sub
+ wait(1.5); //wait
+ torpedo = 0.5; //fire
+ position outside of sub
+ wait (1.0); //wait
+ }
+ }
+ else if (fire==0) {
+ torpedo = 0.01;
+ }*/
+
+ }
+
\ No newline at end of file
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/mbed-os.lib Mon Oct 22 13:43:24 2018 +0000 @@ -0,0 +1,1 @@ +https://github.com/ARMmbed/mbed-os/#e1bea44212b8275f7d8ce7253e758c2e25c57482