public void Initialize() { motor1APin = new OutputGpioPin((GpioPinNumber)motor1APinNo); motor1BPin = new OutputGpioPin((GpioPinNumber)motor1BPinNo); motor2APin = new OutputGpioPin((GpioPinNumber)motor2APinNo); motor2BPin = new OutputGpioPin((GpioPinNumber)motor2BPinNo); }
public static void TestGpio() { var pin11 = new OutputGpioPin(GpioPinNumber.Gpio11); var pin2 = new OutputGpioPin(GpioPinNumber.Gpio17); var pin4 = new InputGpioPin(GpioPinNumber.Gpio4); pin4.Read(); Console.WriteLine("Press ESC to stop"); while (!(Console.KeyAvailable && Console.ReadKey(true).Key == ConsoleKey.Escape)) { pin11.Write(State.Low); Console.WriteLine("Pin 11 : " + pin11.State); pin2.Write(State.High); Console.WriteLine("Pin 2 : " + pin2.State); Thread.Sleep(750); pin11.Write(State.High); Console.WriteLine("Pin 11 : " + pin11.State); pin2.Write(State.Low); Console.WriteLine("Pin 2 : " + pin2.State); Thread.Sleep(750); } pin11.Cleanup(); pin2.Cleanup(); }
private static void PrintStatus(OutputGpioPin pin) { StringBuilder sb = new StringBuilder(); sb.AppendLine("----------Update----------"); //sb.AppendLine("Pin Read: " + pin.Read()); sb.AppendLine("Pin : " + pin.GpioPinNumber); sb.AppendLine("State : " + pin.State); sb.AppendLine("Direction : " + pin.Direction); ResultString = ResultString + sb.ToString(); Console.WriteLine(ResultString); }
public static void AddData(DataModel dataModel) { foreach (var pin in dataModel.PinConfig.Pin) { var pinNo = int.Parse(pin.PinNumber); if (!dictionary.ContainsKey(pinNo)) { GpioPinNumber gpioPinNo = (GpioPinNumber)pinNo; Direction direction = DirectionDictionary[pin.Direction]; State state = StateDictionary[pin.State]; if (direction == Direction.Out) { var outputPin = new OutputGpioPin(gpioPinNo); dictionary.Add(pinNo, outputPin); } } } Console.WriteLine("Add Count : " + dictionary.Count); }
public UltraSonicDistanceSensor(int inputPinNo = 16, int OutputPinNo = 12) { OutputGpioPin OutputPin = new OutputGpioPin((GpioPinNumber)OutputPinNo); InputGpioPin inputPin = new InputGpioPin((GpioPinNumber)inputPinNo); }