Home→Forums→MonoBrick Communication Library→Problem with SetPower→Reply To: Problem with SetPower
March 26, 2014 at 22:04
#4091
Anders Søborg
Keymaster
Hi
When you use the setpower the driver is not enabled – which of cource it should… so this is a bug.
You can fix it your self. Go to motor.cs and locate:
/// <summary>
/// Sets the power of the motor.
/// </summary>
/// <param name="power">Power to use.</param>
/// <param name="reply">If set to <c>true</c> reply from brick will be send.</param>
public void SetPower(byte power, bool reply){
output.SetPower(power, reply);
}
And replace this with
/// <summary>
/// Sets the power of the motor.
/// </summary>
/// <param name="power">Power to use.</param>
/// <param name="reply">If set to <c>true</c> reply from brick will be send.</param>
public void SetPower(byte power, bool reply){
output.SetPower(power, reply);
output.Start(false);
}
once this is done you should be able to use the setpower function like this
using System;
using MonoBrick.EV3;
using System.Threading;
using System.Diagnostics;
public static class Program{
static void Main(string[] args)
{
var ev3 = new Brick<Sensor,Sensor,Sensor,Sensor>("usb");
ev3.Connection.Open();
ev3.MotorA.SetPower(80);
System.Threading.Thread.Sleep(5000);
ev3.MotorA.SetPower(0);
ev3.Connection.Close();
}
}
Thanks
Anders
Follow