This repository has been archived on 2019-06-21. You can view files and clone it, but cannot push or open issues or pull requests.
PixelHub/PixelHub-Client/src/PixelBotController.h

43 lines
1.1 KiB
C++

#pragma once
/// <summary>
/// Connects to a PixelHub server, receives commands, and acts upon them.
/// </summmary>
class PixelBotController
{
public:
PixelBotController();
~PixelBotController();
static const int STOP = 0;
static const int FORWARDS = 1;
static const int BACKWARDS = 2;
static const int LEFT = 3;
static const int RIGHT = 4;
void MoveDistance(int direction, int ticks);
void MoveTick(int direction);
unsigned long GetTicksTravelled();
private:
const int rmotorPin1 = 16;
const int rmotorPin2 = 5;
const int rmotorPin3 = 4;
const int rmotorPin4 = 0;
const int lmotorPin1 = 2;
const int lmotorPin2 = 14;
const int lmotorPin3 = 12;
const int lmotorPin4 = 13;
int motorLookup[8] = { 0b01000, 0b01100, 0b00100, 0b00110, 0b00010, 0b00011, 0b00001, 0b01001 };
int motorSpeed = 1200; // The speed at which the stepper motor accepts bits
unsigned long ticksTravelled = 0; // Number of steps travelled (including turns)
int ticksPerRevolution = 512; // Number of steps per full revolution of the wheels
int tickDelay = 1; // The delay in between ticks
void sendTickPart(int leftCode, int rightCode);
};