
test
Dependents: MouseHybridSenseCode
Diff: funcdef.h
- Revision:
- 5:dfea493f7a12
- Parent:
- 4:f1670eec4681
- Child:
- 6:a652deaae134
--- a/funcdef.h Wed Mar 07 19:27:13 2018 +0000 +++ b/funcdef.h Sun Mar 11 13:15:34 2018 +0000 @@ -1,14 +1,15 @@ -//Define the file once +//Define the file once, in the C and C++ programming languages, an #include guard,is a particular construct used to +//avoid the problem of double inclusion when dealing with the include directive. The addition of #include guards to a header file is one way to make that file idempotent. #ifndef FUNCDEF_H #define FUNCDEF_H //Import Modules -#include "mbed.h" -#include "FastPWM.h" +#include <mbed.h> //Set up PC link (comment out when not using), set up 9600 if using plotter static Serial pc = Serial(USBTX, USBRX); +///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// //Pin Names #define sensor1pin A0 #define sensor2pin A1 @@ -19,38 +20,69 @@ #define sensor7pin A6 #define sensor8pin D3 -#define leftMotorpin D5 -#define rightMotorpin D6 -#define buzzerPin D10 +#define leftMotorpin D6 +#define rightMotorpin D1 +#define beeperPin D10 + +#define Kp 50 +#define Ki 0 +#define Kd 0 +#define Ac 10 +#define period_F6 716 +#define period_E6 758 +#define period_D6 851 +#define period_B6 506 +#define period_A6 568 +//http://www.sengpielaudio.com/calculator-notenames.htm + +///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// //Pin Definitions static DigitalOut LEDVal = DigitalOut(LED1); -//static PwmOut leftMotorVal = PwmOut(leftMotorpin); -//static PwmOut rightMotorVal = PwmOut(rightMotorpin); -static FastPWM leftMotorVal(leftMotorpin,1); -static FastPWM rightMotorVal(rightMotorpin,1); -static PwmOut buzzerVal = PwmOut(buzzerPin); - -//Variable Definitions -static int sensorValue[] = {0,0,0,0,0,0,0,0}; - -static int sensorMinValue[] = {0,0,0,0,0,0,0,0}; -static int sensorMaxValue[] = {0,0,0,0,0,0,0,0}; - -static int sensorMinValue1[] = {0,0,0,0,0,0,0,0}; -static int sensorMaxValue1[] = {0,0,0,0,0,0,0,0}; - -static int sensorMinValue2[] = {0,0,0,0,0,0,0,0}; -static int sensorMaxValue2[] = {0,0,0,0,0,0,0,0}; - -static int sensorThreshold[] = {0,0,0,0,0,0,0,0}; +static PwmOut leftMotorVal=PwmOut(leftMotorpin); +static PwmOut rightMotorVal=PwmOut(rightMotorpin); +static PwmOut beeperVal = PwmOut(beeperPin); static AnalogIn sensorPin[] = {A0,A1,A2,A3,A4,A5,A6,D3}; +///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// +//Global Variable Definitions +extern int sensorValue[8]; + +extern int sensorMinValue[8]; +extern int sensorMaxValue[8]; + +extern int sensorMinValue1[8]; +extern int sensorMaxValue1[8]; + +extern int sensorMinValue2[8]; +extern int sensorMaxValue2[8]; + +extern int sensorThreshold[8]; +extern int sensorErrors[8]; + +extern int Prop; +//extern int Inte; +//extern int Dere; +extern int errorVar; +extern int previousError; +extern int PIDs; +extern int accumulator; +extern int counter; +extern int delayBetweenPulses_ms; +extern int note; +extern int initialMotorspeed; +///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// //Function Definitions + void CalibrateFunc(void); -void func(void); +void printCalibrateValues(void); void beep(int); +void senseFunc(void); +void calculateFunc(void); +void driveFunc(void); +void findLineFunc(void); +void errorAccumulate(void); #endif // FUNCDEF_H \ No newline at end of file