public void SetSpeed(int speed) { if (speed > 255) speed = 255; if (speed < -255) speed = -255; brick.BrickPi.Motor[(int)Port].Speed = speed; //raise the event to notify the UI OnPropertyChanged(nameof(Speed)); }