The markings “M1” and “M2” do not correspond to motor1 and motor2, respectively.
using System;
using System.Collections;
using System.Threading;
using Microsoft.SPOT;
using Microsoft.SPOT.Presentation;
using Microsoft.SPOT.Presentation.Controls;
using Microsoft.SPOT.Presentation.Media;
using Microsoft.SPOT.Touch;
using Gadgeteer.Networking;
using GT = Gadgeteer;
using GTM = Gadgeteer.Modules;
using Gadgeteer.Modules.GHIElectronics;
namespace MotorController
{
public partial class Program
{
// This method is run when the mainboard is powered up or reset.
void ProgramStarted()
{
/*******************************************************************************************
Modules added in the Program.gadgeteer designer view are used by typing
their name followed by a period, e.g. button. or camera.
Many modules generate useful events. Type +=<tab><tab> to add a handler to an event, e.g.:
button.ButtonPressed +=<tab><tab>
If you want to do something periodically, use a GT.Timer and handle its Tick event, e.g.:
GT.Timer timer = new GT.Timer(1000); // every second (1000ms)
timer.Tick +=<tab><tab>
timer.Start();
*******************************************************************************************/
motorControllerL298.MoveMotor(MotorControllerL298.Motor.Motor2, 0);
// The following causes the motor connected to "M2" to turn
motorControllerL298.MoveMotor(MotorControllerL298.Motor.Motor1, 100);
Thread.Sleep(5000);
motorControllerL298.MoveMotor(MotorControllerL298.Motor.Motor1, 0);
// The following causes the motor connected to "M1" to turn
Debug.Print("Ramp up to 100");
motorControllerL298.MoveMotorRamp(MotorControllerL298.Motor.Motor2, 100, 5000);
Thread.Sleep(5000);
Debug.Print("Ramp down to 0");
motorControllerL298.MoveMotorRamp(MotorControllerL298.Motor.Motor2, 0, 5000);
Debug.Print("Ramp down to -100");
motorControllerL298.MoveMotorRamp(MotorControllerL298.Motor.Motor2, -100, 5000);
Thread.Sleep(5000);
Debug.Print("Ramp up to 0");
motorControllerL298.MoveMotorRamp(MotorControllerL298.Motor.Motor2, 0, 5000);
// Use Debug.Print to show messages in Visual Studio's "Output" window during debugging.
Debug.Print("Stop motor");
motorControllerL298.MoveMotor(MotorControllerL298.Motor.Motor1, 0);
}
}
}