private async Task MotorControlSmokeTest() { using (ZumoMotorShield motorDriver = new ZumoMotorShield(Config)) { await motorDriver.Init(); motorDriver.SetLeftMotorPower(ZumoMotorDirection.Forward, 0.3f); await Task.Delay(2000); motorDriver.LeftMotorStop(); await Task.Delay(500); motorDriver.SetLeftMotorPower(ZumoMotorDirection.Backward, 0.3f); await Task.Delay(2000); motorDriver.LeftMotorStop(); await Task.Delay(500); motorDriver.SetLeftMotorPower(ZumoMotorDirection.Forward, 0.3f); await Task.Delay(2000); motorDriver.LeftMotorStop(); await Task.Delay(500); motorDriver.SetLeftMotorPower(ZumoMotorDirection.Backward, 0.3f); await Task.Delay(2000); motorDriver.LeftMotorStop(); await Task.Delay(500); bool flipDir = false; ZumoMotorDirection dirA = ZumoMotorDirection.Forward; ZumoMotorDirection dirB = ZumoMotorDirection.Backward; Debug.WriteLine("Testing Motor Power Control"); for (int i = 20; i <= 100; i += 20) { Debug.WriteLine("Motor Control Ticking"); if (!flipDir) { motorDriver.SetLeftMotorPower(dirA, (float)i / 100.0f); motorDriver.SetRightMotorPower(dirB, (float)i / 100.0f); } else { motorDriver.SetLeftMotorPower(dirB, (float)i / 100.0f); motorDriver.SetRightMotorPower(dirA, (float)i / 100.0f); } flipDir = !flipDir; await Task.Delay(1500); } motorDriver.LeftMotorStop(); motorDriver.RightMotorStop(); } }
private async Task MotorControlSmokeTest() { ZumoMotorShieldConfig config = new ZumoMotorShieldConfig(); config.LeftMotorDirPin = 4; config.RightMotorDirPin = 5; config.LeftPwmChannel = 0; config.RightPwmChannel = 1; config.PwmDriverSlaveAddress = 0x40; config.BuzzerPwmChannel = 2; using (ZumoMotorShield motorDriver = new ZumoMotorShield(config)) { await motorDriver.Init(); bool flipDir = false; ZumoMotorDirection dirA = ZumoMotorDirection.Forward; ZumoMotorDirection dirB = ZumoMotorDirection.Backward; for (int i = 20; i <= 100; i += 20) { Debug.WriteLine("Motor Control Ticking"); if (!flipDir) { motorDriver.SetLeftMotorPower(dirA, (float)i / 100.0f); motorDriver.SetRightMotorPower(dirB, (float)i / 100.0f); } else { motorDriver.SetLeftMotorPower(dirB, (float)i / 100.0f); motorDriver.SetRightMotorPower(dirA, (float)i / 100.0f); } flipDir = !flipDir; await Task.Delay(1500); } motorDriver.LeftMotorStop(); motorDriver.RightMotorStop(); await Task.Delay(1000); motorDriver.SetLeftMotorPower(ZumoMotorDirection.Forward, 0.5f); await Task.Delay(2000); motorDriver.LeftMotorStop(); await Task.Delay(500); motorDriver.SetRightMotorPower(ZumoMotorDirection.Forward, 0.5f); await Task.Delay(2000); motorDriver.RightMotorStop(); } }