Advertisement
Guest User

Untitled

a guest
Feb 2nd, 2016
197
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.14 KB | None | 0 0
  1. using System;
  2. using System.Net;
  3. using System.Net.Sockets;
  4. using System.Threading;
  5. using Microsoft.SPOT;
  6. using Microsoft.SPOT.Hardware;
  7. using SecretLabs.NETMF.Hardware;
  8. using SecretLabs.NETMF.Hardware.Netduino;
  9. using Toolbox.NETMF.Hardware;
  10.  
  11. namespace Playground
  12. {
  13.     public class Program
  14.     {
  15.         public static void Main()
  16.         {
  17.             // Defines the HBridge IC on the correct pins
  18.             HBridge MotorDriver = new HBridge(new Netduino.PWM(Pins.GPIO_PIN_D0), Pins.GPIO_PIN_D1, new Netduino.PWM(Pins.GPIO_PIN_D2), Pins.GPIO_PIN_D3);
  19.  
  20.             while (true)
  21.             {
  22.                 // Motor 1 half speed backward
  23.                 MotorDriver.SetState(HBridge.Motors.Motor1, -50);
  24.  
  25.                 // Lets run for 5 seconds
  26.                 Thread.Sleep(5000);
  27.  
  28.                 // Motor 1 full speed backward
  29.                 MotorDriver.SetState(HBridge.Motors.Motor1, -100);
  30.  
  31.                 // Lets run for 5 seconds
  32.                 Thread.Sleep(5000);
  33.  
  34.                 // Stops both motors
  35.                 MotorDriver.SetState(HBridge.Motors.Motor1, 0);
  36.             }
  37.            
  38.         }
  39.     }
  40. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement