Team Design project 3 main file

Dependencies:   mbed Motor_Driver Sensors MMA8451Q LocalPositionSystem

Fork of TDP_main by Ivelin Kozarev

shooter.h

Committer:
Bartas
Date:
2015-03-25
Revision:
38:02ef89edd828
Parent:
35:1819c5a8254a

File content as of revision 38:02ef89edd828:

/*
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(PTE31); //TESTED WORKING
DigitalOut solenoid(PTA17);

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