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

Dependencies:   HCSR04 MPU6050_1 Motor Servo ledControl2 mbed

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers HALLFX_ENCODER.cpp Source File

HALLFX_ENCODER.cpp

00001 #include "HALLFX_ENCODER.h"
00002  
00003 HALLFX_ENCODER::HALLFX_ENCODER(PinName enc_in): _enc_in(enc_in){
00004     _enc_in.mode(PullUp);
00005     // Invoke interrupt on both falling and rising edges
00006     _enc_in.fall(this, &HALLFX_ENCODER::callback);
00007     _enc_in.rise(this, &HALLFX_ENCODER::callback);
00008 }
00009  
00010 long HALLFX_ENCODER::read(){
00011     return count;
00012 }
00013  
00014 void HALLFX_ENCODER::reset(){
00015     count = 0;
00016 }
00017  
00018 void HALLFX_ENCODER::callback(){
00019     count++;   
00020 }