Team Design project 3 main file

Dependencies:   mbed Motor_Driver Sensors MMA8451Q LocalPositionSystem

Fork of TDP_main by Ivelin Kozarev

Revision:
12:bb21b76b6375
Child:
14:3844d1dacece
diff -r 9e56d52485d1 -r bb21b76b6375 shooter.h
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/shooter.h	Fri Mar 06 16:09:31 2015 +0000
@@ -0,0 +1,40 @@
+/*
+Header file for Shooting mechanism.
+ 
+Takes dutyCycle as a float and converts it t oduty cycle.
+When off- dutyCycle is just switched to 0 duty cycle.
+
+IMPORTANT: need to convert back to dutycycle=0, when not used!! 
+
+Possible improvements:
+-Convert program so when it's off the pins are completely off???  
+-Caclutalate better time for the waits???
+-maybe change the period??
+
+TESTED AND WORKING - 06/03
+IK
+*/
+
+#ifndef _SHOOTER_H
+#define _SHOOTER_H
+
+PwmOut squareOut(PTC9);
+DigitalOut solenoid(PTC8);
+
+void shoot(float dutyCycle) {
+    
+    squareOut.period(0.01f);  // 0.01 second period
+    squareOut.write(dutyCycle);  // 50% duty cycle
+    wait(1.7); // give time for motors to reach optimal speed - is it needed 
+    
+    if (dutyCycle == 0.0) //if not used any more, don't shoot
+        return;
+    
+    solenoid = 1; //push solenoid
+    wait (0.3); // wait needed
+    solenoid = 0;   //pull it back
+     
+    return;   
+}
+
+#endif
\ No newline at end of file