You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: documentation/pins/pins.md
+11-13Lines changed: 11 additions & 13 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -12,9 +12,7 @@ The `Digital` class provides access to the GPIO pins.
12
12
13
13
import Digital from "pins/digital";
14
14
15
-
Pin numbers are device dependent.
16
-
17
-
The Digital class provides only static functions. It is not instantiated.
15
+
Pin numbers and port names are device dependent.
18
16
19
17
### Reading a button
20
18
@@ -27,7 +25,7 @@ The following example configures pin 0 as an input and then tests to see if a bu
27
25
28
26
The static `Digital.read` and `Digital.write` do not allow configuring all pin modes. Use the Digital constructor for full configuration, for example setting the input to use an internal pull-up resistor.
29
27
30
-
let button = new Digital(0, Digital.inputPullUp);
28
+
let button = new Digital(0, Digital.InputPullUp);
31
29
trace(`button state is ${button.read()}`;
32
30
33
31
### Blinking an LED
@@ -46,7 +44,7 @@ The following example configures pin 5 as an output and then blinks it one per s
46
44
To open a GPIO pin on a specific port, use the Digital constructor with the optional first argument.
47
45
48
46
let blink = 1;
49
-
let led = new Digital("gpioPortName", 5);
47
+
let led = new Digital("gpioPortName", 5, Digital.Output);
50
48
51
49
Timer.repeat(id => {
52
50
blink = blink ^ 1;
@@ -55,11 +53,11 @@ To open a GPIO pin on a specific port, use the Digital constructor with the opti
55
53
56
54
### static read(pin)
57
55
58
-
The `read` function sets the pin to `Digital.input` mode and samples the value of the specified pin, returning 0 or 1.
56
+
The `read` function sets the pin to `Digital.Input` mode and samples the value of the specified pin, returning 0 or 1. The default port is used.
59
57
60
58
### static write(pin)
61
59
62
-
The `write` function sets the pin to `Digital.output` mode and its value to either 0 or 1.
60
+
The `write` function sets the pin to `Digital.Output` mode and its value to either 0 or 1. The default port is used.
63
61
64
62
### constructor([port], pin, mode)
65
63
@@ -69,12 +67,12 @@ The Digital constructor establishes a connection to the GPIO pin specified by th
69
67
70
68
The mode function sets the mode of the pin. Not all pins support all modes, so refer to the hardware documentation for details. The following mode values are available.
0 commit comments