Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

TinyGo drivers for sensors, displays, wireless adaptors, and other devices that use I2C, SPI, GPIO, ADC, and UART interfaces.

License

NotificationsYou must be signed in to change notification settings

tinygo-org/drivers

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

PkgGoDevBuild

This package provides a collection of over 100 different hardware drivers for devices such as sensors, displays, wireless adaptors, and actuators, that can be used together withTinyGo.

For the complete list, please see:https://tinygo.org/docs/reference/devices/

Installing

go get tinygo.org/x/drivers

How to use

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

package mainimport ("time""machine""tinygo.org/x/drivers/bmp180")funcmain() {machine.I2C0.Configure(machine.I2CConfig{})sensor:=bmp180.New(machine.I2C0)sensor.Configure()connected:=sensor.Connected()if!connected {println("BMP180 not detected")return    }println("BMP180 detected")for {temp,_:=sensor.ReadTemperature()println("Temperature:",float32(temp)/1000,"°C")pressure,_:=sensor.ReadPressure()println("Pressure",float32(pressure)/100000,"hPa")time.Sleep(2*time.Second)    }}

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:

var (spi=machine.SPI0csPin=machine.D5)

It might not be obvious, but you need to change these to match how you wired your specific board. Constants aredefined for each supported microcontroller.

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

var (spi=machine.SPI0csPin=machine.GP17)

Contributing

Your contributions are welcome!

Please take a look at ourCONTRIBUTING.md document for details.

License

This project is licensed under the BSD 3-clause license, just like theGo project itself.

About

TinyGo drivers for sensors, displays, wireless adaptors, and other devices that use I2C, SPI, GPIO, ADC, and UART interfaces.

Topics

Resources

License

Contributing

Stars

Watchers

Forks

Packages

No packages published

Contributors93

Languages


[8]ページ先頭

©2009-2025 Movatter.jp