Prototype program for balancing robot based on various examples from other users.

Dependencies:   HCSR04 MPU6050_1 Motor Servo ledControl2 mbed

HALLFX_ENCODER.cpp

Committer:
lakshmananag
Date:
2016-08-26
Revision:
0:cfae0986065f

File content as of revision 0:cfae0986065f:

#include "HALLFX_ENCODER.h"
 
HALLFX_ENCODER::HALLFX_ENCODER(PinName enc_in): _enc_in(enc_in){
    _enc_in.mode(PullUp);
    // Invoke interrupt on both falling and rising edges
    _enc_in.fall(this, &HALLFX_ENCODER::callback);
    _enc_in.rise(this, &HALLFX_ENCODER::callback);
}
 
long HALLFX_ENCODER::read(){
    return count;
}
 
void HALLFX_ENCODER::reset(){
    count = 0;
}
 
void HALLFX_ENCODER::callback(){
    count++;   
}