You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 

54 lines
1.0 KiB

#ifndef _TANKDRIVE_H // not #ifnotdef
#define _TANKDRIVE_H
#include "Motorz.h"
class TankDrive
{
Motorz *motorL;
Motorz *motorR;
int forwardR,forwardL,backR,backL;
public:
TankDrive(Motorz *MR,int fr,Motorz *ML,int fl){
motorL=ML;
motorR=MR;
forwardR=fr;
forwardL=fl;
if(fr==1)backR=0;
else backR=1;
if(fl==1)backL=0;
else backL=1;
}
void MoveForward(){
motorR->SetDirection(forwardR);
motorL->SetDirection(forwardL);
motorR->Start();
motorL->Start();
}
void MoveBack(){
motorR->SetDirection(backR);
motorL->SetDirection(backL);
motorR->Start();
motorL->Start();
}
void Stop(){
motorL->Stop();
motorR->Stop();
}
void TurnRight(){
motorR->SetDirection(backR);
motorL->SetDirection(forwardL);
motorR->Start();
motorL->Start();
}
void Turnleft(){
motorR->SetDirection(forwardR);
motorL->SetDirection(backL);
motorL->Start();
motorR->Start();
}
};
#endif _TANKDRIVE_H