123456789101112131415161718192021222324252627282930313233343536373839404142 |
- using Iot.Device.Pigpio;
- using System;
- using System.Device.Gpio;
- using System.Net;
- using System.Threading;
- using System.Threading.Tasks;
-
- namespace ConsoleApp9
- {
- class Program
- {
- static async Task Main(string[] args)
- {
- var addr = "80.11.204.244";
- var port = 9031;
- var pin = 12;
- // var blinks = 5;
-
- using (var driver = new Driver(new IPEndPoint(IPAddress.Parse(addr), port)))
- {
- await driver.ConnectAsync();
- await Task.Delay(TimeSpan.FromSeconds(1)); //Give the socket time to get connected
-
- Console.WriteLine("Connected");
-
- using (var controller = new GpioController(PinNumberingScheme.Logical, driver))
- {
- controller.OpenPin(pin);
- controller.SetPinMode(pin, PinMode.InputPullUp);
-
- while (true)
- {
- controller.WaitForEvent(pin, PinEventTypes.Falling, new CancellationToken(false));
- Console.WriteLine("Beep boop");
- }
-
- controller.ClosePin(pin);
- }
- }
- }
- }
- }
|