encoder test
Revision 0:48d483ff099a, committed 2019-02-16
- Comitter:
- kenken0721
- Date:
- Sat Feb 16 01:12:54 2019 +0000
- Commit message:
Changed in this revision
| main.cpp | Show annotated file Show diff for this revision Revisions of this file |
| mbed.bld | Show annotated file Show diff for this revision Revisions of this file |
--- /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
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/mbed.bld Sat Feb 16 01:12:54 2019 +0000 @@ -0,0 +1,1 @@ +https://os.mbed.com/users/mbed_official/code/mbed/builds/3a7713b1edbc \ No newline at end of file