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.
Dependencies: mbed SoftPWM Servo_softpwm IR2302
Diff: main.cpp
- Revision:
 - 0:710db3044013
 - Child:
 - 1:e385a2004a95
 
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/main.cpp	Tue Sep 28 02:09:17 2021 +0000
@@ -0,0 +1,41 @@
+#include "mbed.h"
+#include "Servo.h"
+#include "ikarashiMDC.h"
+ 
+DigitalOut stop(D13);
+Serial serial(PC_10,PC_11,115200);
+Serial pc(USBTX, USBRX,115200);
+Timer t;
+Servo servo[6]={PB_15,PB_10,PB_4,PB_5,PB_3,PA_10};
+
+ikarashiMDC motor[] = {
+    ikarashiMDC(0,0,SM,&serial),
+    ikarashiMDC(0,1,SM,&serial),
+    ikarashiMDC(0,2,SM,&serial),
+    ikarashiMDC(0,3,SM,&serial)
+};
+
+int main()
+{
+    stop=1;
+    float servoValue[6]={0.0,0.0,0.0,0.0,0.0,0.0};
+    float time;
+    int i;
+    for(i=0;i<6;i++){
+        servo[i].calibrate(0.00095, 90);
+    }
+    t.start();
+    while(1){
+        time=t.read();
+        for(i=0;i<6;i++){
+            servoValue[i]=(sin(time)+1.0)/2.0;
+        }
+                // サーボの値をservoValueに代入(0度が0,90度が0.5,180度が1.0)
+        for(int i=0; i<4; i++){
+            motor[i].setSpeed(sin(2.0*3.14*0.2*t.read())*0.5);
+        }
+        for(i=0;i<6;i++){
+            servo[i].write(servoValue[i]);
+        }
+    }
+}