public void setSpeedRight(Smc device, short speed) { try { // Find a device and temporarily connect. { device.resume(); // Clear as many errors as possible. device.setSpeed(speed); // Set the speed to full forward (+100%). } } catch (Exception exception) // Handle exceptions by displaying them to the user. { Console.WriteLine(exception.Message); device.stop(); } }
public void stop(List <DeviceListItem> deviceList) { try { // Find a device and temporarily connect. foreach (var dev in deviceList) { Smc device = new Smc(dev); device.stop(); } } catch (Exception exception) // Handle exceptions by displaying them to the user. { Console.WriteLine(exception.Message); } }
/// <summary> /// This function runs when the user clicks the Stop button. /// </summary> void stopButton_Click(object sender, EventArgs e) { try { using (Smc device = connectToDevice()) // Find a device and temporarily connect. { device.stop(); // Activate the USB kill switch // Alternatively you can set the speed to 0 to stop the motor, // but that will only stop the motor if the input mode is Serial/USB: // device.setSpeed(0); } } catch (Exception exception) // Handle exceptions by displaying them to the user. { displayException(exception); } }
public static void stop(Smc device) { device.stop(); }
/// <summary> /// Stops the motor moving /// </summary> public void StopMotor() { motor.stop(); // this however activates the USB kill switch, perhaps change this to SetSpeed(0)? }