protected override void OnCreate(Bundle savedInstanceState) { base.OnCreate(savedInstanceState); SetContentView(Resource.Layout.Main); var btnCount = FindViewById <Button> (Resource.Id.btnCount); var btnLight = FindViewById <Button> (Resource.Id.btnLight); var btnNext = FindViewById <Button> (Resource.Id.btnNext); IIoTButton iotButton = new IoTButton(Connectors.GPIO17); IIoTRelay iotRelay = new IoTRelay(Connectors.GPIO27); HubContext.Configure(iotRelay, iotButton); btnCount.Click += delegate { btnCount.Text = $"{count++} clicks!"; }; //Binds real IoT button with a Android.Button behaviour iotButton.Bind(btnCount); //Binds Android.Button automatically button with relay toggle action btnLight.Bind(iotRelay, 0); btnLight.Click += delegate { iotRelay.Toggle(0); }; btnNext.Text = "Back"; btnNext.Click += delegate { Finish(); }; }
public RelayTest() { var relay = new IoTRelay(Connectors.GPIO17, Connectors.GPIO27); while (count < max) { relay.Toggle(0); if (count % 2 == 0) { var pinValue = relay.GetPinValue(1); relay.EnablePin(1, !pinValue); } relay.Update(); Thread.Sleep(500); count++; } relay.Dispose(); }