Advertisement
peony3000

Gadgeteer Motor Code (Untested)

Apr 9th, 2012
120
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 2.99 KB | None | 0 0
  1. using System;
  2. using Microsoft.SPOT;
  3. using Microsoft.SPOT.Presentation;
  4. using Microsoft.SPOT.Presentation.Controls;
  5. using Microsoft.SPOT.Presentation.Media;
  6.  
  7. using Microsoft.SPOT.Hardware;
  8. using System.Threading;
  9.  
  10. using GT = Gadgeteer;
  11. using GTM = Gadgeteer.Modules;
  12. using GTI = Gadgeteer.Interfaces;
  13. using Gadgeteer.Modules.GHIElectronics;
  14.  
  15. namespace MotorControllerTester
  16. {
  17.     public partial class Program
  18.     {
  19.         void ProgramStarted()
  20.         {
  21.             /******************************************************************************************
  22.             Access modules defined in the designer by typing their name:                            
  23.            
  24.             e.g.  button
  25.                   camera1
  26.  
  27.             Initialize event handlers here.
  28.             e.g. button.ButtonPressed += new GTM.MSR.Button.ButtonEventHandler(button_ButtonPressed);            
  29.             ***************************************************************************************** */
  30.             MotorControllerL298 motorController = new MotorControllerL298(11);
  31.  
  32.             //for( int i = 0; i < 100; i++ )
  33.             //    temp.MoveMotor(MotorControllerL298.Motor.Motor1, i);
  34.  
  35.             motorController.MoveMotor(MotorControllerL298.Motor.Motor1, 0);
  36.             motorController.MoveMotor(MotorControllerL298.Motor.Motor2, 0);
  37.  
  38. #if TRUE
  39.             motorController.MoveMotorRamp(MotorControllerL298.Motor.Motor1, 100, 5000);
  40.             Debug.Print("going down");
  41.             motorController.MoveMotorRamp(MotorControllerL298.Motor.Motor1, 0, 5000);
  42.             Debug.Print("going moar down");
  43.             motorController.MoveMotorRamp(MotorControllerL298.Motor.Motor1, -100, 5000);
  44.             Debug.Print("going up");
  45.             motorController.MoveMotorRamp(MotorControllerL298.Motor.Motor1, 0, 5000);
  46.             Debug.Print("moar ups");
  47.             motorController.MoveMotorRamp(MotorControllerL298.Motor.Motor1, 100, 5000);
  48.  
  49.             Debug.Print("OTHER SIDE");
  50.  
  51.             motorController.MoveMotorRamp(MotorControllerL298.Motor.Motor2, 100, 5000);
  52.             Debug.Print("going down");
  53.             motorController.MoveMotorRamp(MotorControllerL298.Motor.Motor2, 0, 5000);
  54.             Debug.Print("going moar down");
  55.             motorController.MoveMotorRamp(MotorControllerL298.Motor.Motor2, -100, 5000);
  56.             Debug.Print("going up");
  57.             motorController.MoveMotorRamp(MotorControllerL298.Motor.Motor2, 0, 5000);
  58.             Debug.Print("moar ups");
  59.             motorController.MoveMotorRamp(MotorControllerL298.Motor.Motor2, 100, 5000);
  60. #else
  61.             motorController.MoveMotorRampNB(MotorControllerL298.Motor.Motor1, 100, 5000);
  62.             motorController.MoveMotorRampNB(MotorControllerL298.Motor.Motor1, 100, 5000);
  63.  
  64.             Thread.Sleep(500);
  65.  
  66.             motorController.MoveMotorRampNB(MotorControllerL298.Motor.Motor2, -100, 5000);
  67.  
  68. #endif
  69.             // Do one-time tasks here
  70.             Debug.Print("Program Started");
  71.         }
  72.     }
  73. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement