From 07216d3051aa2137af6b887b7109c7b99b2028f7 Mon Sep 17 00:00:00 2001 From: Greg Herlein Date: Wed, 14 Aug 2024 11:27:05 -0700 Subject: [PATCH] expanded README to discuss need to change variables in examples --- README.md | 24 +++++++++++++++++++++++- 1 file changed, 23 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 4b5a86d..5d4f0fd 100644 --- a/README.md +++ b/README.md @@ -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 @@ -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!