

| 10秒間走らせる | |
|---|---|
public static void Main()
{
ServoMotor Rightsv = new ServoMotor(Cpu.PWMChannel.PWM_1);
Rightsv.update(1100, 20000);
Rightsv.Start();
CPU.delay(10000); // 10秒間走らせる
Rightsv.Stop(); // 止める
Rightsv.Dispose();
}
|
1 2 3 PWM_1はPA7である 4 Rightsv.SetSpeed(1100);でも良い 5 単位は0.1μsである 6 単位は1ms 7 8 9 |

| 割り込みボタンで停止させる |
|---|
public static void Main()
{
ServoMotor Rightsv = new ServoMotor(Cpu.PWMChannel.PWM_1);
ServoMotor Leftsv = new ServoMotor(Cpu.PWMChannel.PWM_3);
// CPU.P1(PB8[P16])で割り込んでストップさせる
ServoMotor.setInterrupt(GHI.OSHW.Hardware.FEZCerberus.Pin.PB8);
Rightsv.SetSpeed(1100);
Leftsv.SetSpeed(1600);
Rightsv.Start();
Leftsv.Start();
while (true)
{
if (ServoMotor.stopState) break;
}
Rightsv.Stop(); // 止める
Leftsv.Stop();
Rightsv.Dispose();
Leftsv.Dispose();
}
|