David's line following code from the LVBots competition, 2015.

Dependencies:   GeneralDebouncer Pacer PololuEncoder mbed

Fork of DeadReckoning by David Grayson

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,   // Gray wire
00004               encoderPinLeftB = p7,   // White wire
00005               encoderPinRightA = p30,  // White wire
00006               encoderPinRightB = p29;  // Gray 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 }