encoder test

Dependencies:   mbed

main.cpp

Committer:
kenken0721
Date:
2019-02-16
Revision:
0:48d483ff099a

File content as of revision 0:48d483ff099a:

#include "mbed.h"

Serial PC(USBTX,USBRX);
InterruptIn A(A0);
DigitalIn B(A1);

long Count = 0;

void Arise(){
    if(int(B) == 0){
        Count++;
    }else{
        Count--;
    }
    PC.printf("ok");
        
}

int main() {
    A.mode(PullUp);
    B.mode(PullUp);
    A.rise(&Arise);
    
    while (true) {
        PC.printf("%d \n",Count);
        
    }
}