David's dead reckoning code for the LVBots competition on March 6th. Uses the mbed LPC1768, DRV8835, QTR-3RC, and two DC motors with encoders.

Dependencies:   PololuEncoder Pacer mbed GeneralDebouncer

encoders.cpp

Committer:
DavidEGrayson
Date:
2019-08-13
Revision:
48:597738b77f77
Parent:
39:b19dfc5d4d4b

File content as of revision 48:597738b77f77:

#include "encoders.h"

const PinName encoderPinLeftA = p6,   // White wire
              encoderPinLeftB = p7,   // Yellow wire
              encoderPinRightA = p30,  // Yellow wire
              encoderPinRightB = p29;  // White wire

PololuEncoderBuffer encoderBuffer;
PololuEncoder encoderLeft(encoderPinLeftA, encoderPinLeftB, &encoderBuffer, ENCODER_LEFT);
PololuEncoder encoderRight(encoderPinRightA, encoderPinRightB, &encoderBuffer, ENCODER_RIGHT);

void encodersInit()
{
    DigitalIn(encoderPinLeftA).mode(PullNone);
    DigitalIn(encoderPinLeftB).mode(PullNone);
    DigitalIn(encoderPinRightA).mode(PullNone);
    DigitalIn(encoderPinRightB).mode(PullNone);
    wait_us(50);
    encoderLeft.init();
    encoderRight.init();   
}