Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Diff: main.cpp
- Revision:
- 0:4d8fe7b64edd
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/main.cpp Thu Oct 24 07:12:51 2019 +0000
@@ -0,0 +1,32 @@
+#include "mbed.h"
+
+InterruptIn enc(D12); //シュミットトリガ立ち上がり回数をカウント
+DigitalOut led(LED1);
+PwmOut mot_a(D9);
+PwmOut mot_b(D3);
+
+int counter = 0;
+
+void event_handler(void) {
+ counter++;
+ led = !led;
+}
+
+void mode0(float a, float b){
+ mot_a = a;
+ mot_b = b;
+}
+
+int main() {
+ mot_a.period(0.01f);
+ mot_b.period(0.01f);
+
+ enc.rise(&event_handler);
+
+ while(1) {
+ mode0(1.0f,0.0f); //正転、duty100%
+ printf("%d\n", counter);
+ counter = 0;
+ wait(1.0);
+ }
+}
\ No newline at end of file