Skip to content

Commit ea2d317

Browse files
Update README.md
1 parent a593955 commit ea2d317

File tree

1 file changed

+14
-1
lines changed

1 file changed

+14
-1
lines changed

README.md

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ redLED.Voltage = Voltage.Low; //off
5555

5656
All of the above examples assume the default `Direct` power mode, where the positive terminal of the LED is connected to the GPIO pin, and the negative terminal is connected to the ground pin.
5757

58-
If, instead, you want to supply constant power by, e.g. the `3v3` pin, and the have the GPIO pin supply (or not supply) resistance, you can use the `Differential` power mode, where `PowerValue.On == Voltage.Low` and `PowerValue.Off == Voltage.High`:
58+
If, instead, you want to supply constant power by, e.g. the 3v3 pin, and the have the GPIO pin supply (or not supply) resistance, you can use the `Differential` power mode, where `PowerValue.On == Voltage.Low` and `PowerValue.Off == Voltage.High`:
5959
```C#
6060
var yellowLED = pi.Pin18;
6161
yellowLED.PowerMode = PowerMode.Differential;
@@ -90,6 +90,19 @@ var isPressed = button.Power == PowerValue.On;
9090

9191
The `Direct` Power Mode for an input component expects power from e.g. the 3v3 pin, so that electricity flows through to the GPIO pin when the button is depressed.
9292

93+
## Reacting to Change
94+
95+
Three methods are provided on a pin that accept an `Action` as a parameter, so that when that pin's state changes, some subsequent steps can be performed:
96+
```C#
97+
var button = pi.Pin11;
98+
var redLED = pi.Pin16;
99+
var buzzer = pi.Pin18;
100+
101+
button.OnPowerOn(() => redLED.TurnOn());
102+
button.OnPowerOff(() => redLED.TurnOff());
103+
redLED.OnPowerChange(() => buzzer.Toggle(1, 1));
104+
```
105+
93106
## Cleaning up
94107

95108
If you want to turn off everything that was turned on while your application was running, simply `Dispose()` of your `RaspberryPi` at the end of your code.

0 commit comments

Comments
 (0)