Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/flx/LSM303
LSM303 Accelerometer access through Swift on Raspberry Pi
https://github.com/flx/LSM303
Last synced: about 1 month ago
JSON representation
LSM303 Accelerometer access through Swift on Raspberry Pi
- Host: GitHub
- URL: https://github.com/flx/LSM303
- Owner: flx
- License: gpl-3.0
- Created: 2019-01-21T13:33:30.000Z (almost 6 years ago)
- Default Branch: master
- Last Pushed: 2019-01-27T16:29:25.000Z (almost 6 years ago)
- Last Synced: 2024-10-29T08:43:47.735Z (about 1 month ago)
- Language: Swift
- Size: 21.5 KB
- Stars: 3
- Watchers: 1
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
- awesome-embedded-swift - LSM303 - LSM303 Accelerometer access through Swift on Raspberry Pi (Sensors / Networking, IoT, Bus Protocols, …)
README
# LSM303
A Swift driver for the LSM303DLHC controller over I2C, using SwiftyGPIO. The code has been tested with the FLORA sensor sold by Adafruit (https://www.adafruit.com/product/1247).
```swift
import Foundation
import LSM303print("start")
let lsm303 = LSM303(for: .RaspberryPi3)
lsm303.setAccScale(scale: .G2)
lsm303.setMagGain(gain: .GAIN_1_3)while (true) {
lsm303.read()
print("accel \(lsm303.accel.x) \(lsm303.accel.y) \(lsm303.accel.z) mag \(lsm303.mag.x) \(lsm303.mag.y) \(lsm303.mag.z)")
}
```