Skip to content

Commit 07216d3

Browse files
gherleindeadprogram
authored andcommitted
expanded README to discuss need to change variables in examples
1 parent d688fa3 commit 07216d3

File tree

1 file changed

+23
-1
lines changed

1 file changed

+23
-1
lines changed

README.md

+23-1
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ go get tinygo.org/x/drivers
1616

1717
## How to use
1818

19-
Here is an example in TinyGo that uses the BMP180 digital barometer:
19+
Here is an example in TinyGo that uses the BMP180 digital barometer. This example should work on any board that supports I2C:
2020

2121
```go
2222
package main
@@ -53,6 +53,28 @@ func main() {
5353
}
5454
```
5555

56+
## Examples Using GPIO or SPI
57+
58+
If compiling these examples directly you are likely to need to make minor changes to the defined variables to map the pins for the board you are using. For example, this block in main.go:
59+
60+
```golang
61+
var (
62+
spi = machine.SPI0
63+
csPin = machine.D5
64+
)
65+
```
66+
67+
It might not be obvious, but you need to change these to match how you wired your specific board. Constants are [defined for each supported microcontroller](https://tinygo.org/docs/reference/microcontrollers/).
68+
69+
For example, to change the definitions for use on a Raspberry Pi Pico using typical wiring, you might need to do this:
70+
71+
```golang
72+
var (
73+
spi = machine.SPI0
74+
csPin = machine.GP17
75+
)
76+
```
77+
5678
## Contributing
5779

5880
Your contributions are welcome!

0 commit comments

Comments
 (0)