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:629c15c833cf
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/main.cpp Thu Oct 31 05:24:48 2019 +0000
@@ -0,0 +1,35 @@
+#include "mbed.h"
+#include "motor.h"
+
+Motor motor1(D5, D4);
+DigitalOut motor_mode(D13);
+InterruptIn iin(D12);
+Ticker timer1;
+Ticker timer2;
+
+void PGsensor()
+{
+ motor1.count();
+}
+
+void rpm_of_motor()
+{
+ motor1.calc_rpm();
+}
+
+void control_motor()
+{
+ motor1.drive();
+}
+
+int main()
+{
+ motor1.Set_target(3000);
+ motor1.Set_phase(1);
+
+ iin.rise(&PGsensor);
+ iin.fall(&PGsensor);
+
+ timer1.attach(&rpm_of_motor, motor1.MEASUREMENT_INTERVAL);
+ timer2.attach(&control_motor, motor1.MEASUREMENT_INTERVAL);
+}
\ No newline at end of file