ケンタ ミヤザキ
/
encoder01
encoder test
Diff: main.cpp
- Revision:
- 0:48d483ff099a
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/main.cpp Sat Feb 16 01:12:54 2019 +0000 @@ -0,0 +1,28 @@ +#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); + + } +} \ No newline at end of file