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

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers encoders.cpp Source File

encoders.cpp

00001 #include "encoders.h"
00002 
00003 const PinName encoderPinLeftA = p6,   // White wire
00004               encoderPinLeftB = p7,   // Yellow wire
00005               encoderPinRightA = p30,  // Yellow wire
00006               encoderPinRightB = p29;  // White wire
00007 
00008 PololuEncoderBuffer encoderBuffer;
00009 PololuEncoder encoderLeft(encoderPinLeftA, encoderPinLeftB, &encoderBuffer, ENCODER_LEFT);
00010 PololuEncoder encoderRight(encoderPinRightA, encoderPinRightB, &encoderBuffer, ENCODER_RIGHT);
00011 
00012 void encodersInit()
00013 {
00014     DigitalIn(encoderPinLeftA).mode(PullNone);
00015     DigitalIn(encoderPinLeftB).mode(PullNone);
00016     DigitalIn(encoderPinRightA).mode(PullNone);
00017     DigitalIn(encoderPinRightB).mode(PullNone);
00018     wait_us(50);
00019     encoderLeft.init();
00020     encoderRight.init();   
00021 }