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.
main.cpp
- Committer:
- yasunorihirakawa
- Date:
- 2019-10-31
- Revision:
- 0:629c15c833cf
File content as of revision 0:629c15c833cf:
#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);
}