Skip to content

Commit

Permalink
expanded README to discuss need to change variables in examples
Browse files Browse the repository at this point in the history
  • Loading branch information
gherlein authored and deadprogram committed Aug 25, 2024
1 parent d688fa3 commit 07216d3
Showing 1 changed file with 23 additions and 1 deletion.
24 changes: 23 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ go get tinygo.org/x/drivers

## How to use

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

```go
package main
Expand Down Expand Up @@ -53,6 +53,28 @@ func main() {
}
```

## Examples Using GPIO or SPI

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:

```golang
var (
spi = machine.SPI0
csPin = machine.D5
)
```

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/).

For example, to change the definitions for use on a Raspberry Pi Pico using typical wiring, you might need to do this:

```golang
var (
spi = machine.SPI0
csPin = machine.GP17
)
```

## Contributing

Your contributions are welcome!
Expand Down

0 comments on commit 07216d3

Please sign in to comment.