No Description
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

Program.cs 1.2KB

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. using Iot.Device.Pigpio;
  2. using System;
  3. using System.Device.Gpio;
  4. using System.Net;
  5. using System.Threading;
  6. using System.Threading.Tasks;
  7. namespace ConsoleApp9
  8. {
  9. class Program
  10. {
  11. static async Task Main(string[] args)
  12. {
  13. var addr = "80.11.204.244";
  14. var port = 9031;
  15. var pin = 12;
  16. // var blinks = 5;
  17. using (var driver = new Driver(new IPEndPoint(IPAddress.Parse(addr), port)))
  18. {
  19. await driver.ConnectAsync();
  20. await Task.Delay(TimeSpan.FromSeconds(1)); //Give the socket time to get connected
  21. Console.WriteLine("Connected");
  22. using (var controller = new GpioController(PinNumberingScheme.Logical, driver))
  23. {
  24. controller.OpenPin(pin);
  25. controller.SetPinMode(pin, PinMode.InputPullUp);
  26. while (true)
  27. {
  28. controller.WaitForEvent(pin, PinEventTypes.Falling, new CancellationToken(false));
  29. Console.WriteLine("Beep boop");
  30. }
  31. controller.ClosePin(pin);
  32. }
  33. }
  34. }
  35. }
  36. }