Created
June 28, 2016 06:35
-
-
Save inderpreet/4b65ef79945c6789245f9e3ed2da9ff0 to your computer and use it in GitHub Desktop.
chassis_objects
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Class for Chassis | |
/* ********* | |
usage: | |
chassis obj(P1_0, P1_6, P1_2, P1_1); // This creates an object for the chassis class | |
chassis obj(A1, A0, A2, A3); | |
chassis obj(P1_0, P1_6, P1_2, P1_1, 127); | |
obj.forward(700); | |
chassis.obj347(dslkfhjdslkfjs); | |
************/ | |
#define FWD HIGH | |
#define BKW LOW | |
class chassis{ | |
public: | |
// Varibles for Pins | |
int pEnable1, pEnable2, pDir1, pDir2; | |
int iSpeedMax; | |
int a; | |
//Default Constructor | |
chassis(void){ | |
iSpeedMax=0; | |
this.a=6; | |
} | |
// Constructor | |
chassis(int a, int b, int c, int d){ | |
// Set the Pin Values | |
this.a=a; | |
pDir1=a; | |
pEnable1=b; | |
pEnable2=c; | |
pDir2=d; | |
iSpeedMax=255; | |
// Inital configuration for the pins | |
pinMode(pEnable1, OUTPUT); | |
pinMode(pEnable2, OUTPUT); | |
pinMode( pDir1, OUTPUT); | |
pinMode( pDir2, OUTPUT); | |
digitalWrite(pDir1, FWD); // Set Inital Direction to HIGH? | |
digitalWrite(pDir2, FWD); | |
analogWrite(pEnable1, 0x00); // Set initial speed to zero | |
analogWrite(pEnable2, 0x00); | |
} | |
// Constructor | |
chassis(int a, int b, int c, int d, int e){ | |
// Set the Pin Values | |
pDir1=a; | |
pEnable1=b; | |
pEnable2=c; | |
pDir2=d; | |
iSpeedMax=e; | |
// Inital configuration for the pins | |
pinMode(pEnable1, OUTPUT); | |
pinMode(pEnable2, OUTPUT); | |
pinMode( pDir1, OUTPUT); | |
pinMode( pDir2, OUTPUT); | |
digitalWrite(pDir1, FWD); // Set Inital Direction to HIGH? | |
digitalWrite(pDir2, FWD); | |
analogWrite(pEnable1, 0x00); // Set initial speed to zero | |
analogWrite(pEnable2, 0x00); | |
} | |
// Function Prototypes | |
void forward(int a){ | |
digitalWrite(pDir1, FWD); | |
digitalWrite(pDir2, FWD); | |
analogWrite(pEnable1, iSpeedMax); | |
analogWrite(pEnable2, iSpeedMax); | |
delay(a); | |
analogWrite(pEnable1, 0); | |
analogWrite(pEnable2, 0); | |
} | |
void backward(int a); | |
void right(int a); | |
void left(int a); | |
}; | |
void backward::chassis (int a){ | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment