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:
2014-02-22
Revision:
8:78b1ff957cba
Child:
9:9734347b5756

File content as of revision 8:78b1ff957cba:

#include "encoders.h"

const PinName encoderPin1A = p6,
              encoderPin1B = p7,
              encoderPin2A = p8,
              encoderPin2B = p9;

PololuEncoderBuffer encoderBuffer;
PololuEncoder encoder1(encoderPin1A, encoderPin1B, &encoderBuffer, ENCODER1);
PololuEncoder encoder2(encoderPin2A, encoderPin2B, &encoderBuffer, ENCODER2);

void encoders_init()
{
    DigitalIn(encoderPin1A).mode(PullUp);
    DigitalIn(encoderPin1B).mode(PullUp);
    DigitalIn(encoderPin2A).mode(PullUp);
    DigitalIn(encoderPin2B).mode(PullUp);
    wait_us(50);
    encoder1.init();
    encoder2.init();   
}