2016-06-05 23:00:37 +02:00
|
|
|
# L3G4200D Module
|
|
|
|
| Since | Origin / Contributor | Maintainer | Source |
|
|
|
|
| :----- | :-------------------- | :---------- | :------ |
|
|
|
|
| 2015-04-09 | [Jason Schmidlapp](https://github.com/jschmidlapp) | [Jason Schmidlapp](https://github.com/jschmidlapp) | [l3g4200d.c](../../../app/modules/l3g4200d.c)|
|
|
|
|
|
|
|
|
|
2016-06-05 23:42:21 +02:00
|
|
|
This module provides access to the [L3G4200D](https://www.sparkfun.com/products/10612) three axis digital gyroscope.
|
2016-06-05 23:00:37 +02:00
|
|
|
|
|
|
|
## l3g4200d.read()
|
|
|
|
Samples the sensor and returns the gyroscope output.
|
|
|
|
|
|
|
|
#### Syntax
|
|
|
|
`l3g4200d.read()`
|
|
|
|
|
|
|
|
#### Returns
|
|
|
|
X,Y,Z gyroscope output
|
|
|
|
|
|
|
|
#### Example
|
|
|
|
```lua
|
2017-05-21 16:17:29 +02:00
|
|
|
local sda, scl = 1, 2
|
|
|
|
i2c.setup(0, sda, scl, i2c.SLOW) -- call i2c.setup() only once
|
|
|
|
l3g4200d.setup()
|
2016-06-05 23:00:37 +02:00
|
|
|
local x,y,z = l3g4200d.read()
|
|
|
|
print(string.format("X = %d, Y = %d, Z = %d", x, y, z)
|
|
|
|
```
|
|
|
|
|
|
|
|
## l3g4200d.init()
|
|
|
|
Initializes the module and sets the pin configuration.
|
|
|
|
|
2017-05-21 16:17:29 +02:00
|
|
|
!!! attention
|
|
|
|
|
|
|
|
This function is deprecated and will be removed in upcoming releases. Use `l3g4200d.setup()` instead.
|
|
|
|
|
2016-06-05 23:00:37 +02:00
|
|
|
#### Syntax
|
|
|
|
`l3g4200d.init(sda, scl)`
|
|
|
|
|
|
|
|
#### Parameters
|
|
|
|
- `sda` data pin
|
|
|
|
- `scl` clock pin
|
|
|
|
|
|
|
|
#### Returns
|
|
|
|
`nil`
|
2017-05-21 16:17:29 +02:00
|
|
|
|
|
|
|
## l3g4200d.setup()
|
|
|
|
Initializes the module.
|
|
|
|
|
|
|
|
#### Syntax
|
|
|
|
`l3g4200d.setup()`
|
|
|
|
|
|
|
|
#### Parameters
|
|
|
|
None
|
|
|
|
|
|
|
|
#### Returns
|
|
|
|
`nil`
|