Mercurial > d1mini-18ch-servo
changeset 4:f614c50ac75a
Add an Arduino library
| author | Radomir Dopieralski <sheep-devel@sheep.art.pl> |
|---|---|
| date | Sun, 09 Oct 2016 12:25:21 +0200 |
| parents | d20600cfb6fd |
| children | 0c868a2c7cda |
| files | arduino/D1Servo18/D1Servo18.cpp arduino/D1Servo18/D1Servo18.h arduino/D1Servo18/examples/center/center.ino arduino/D1Servo18/library.properties |
| diffstat | 4 files changed, 58 insertions(+), 0 deletions(-) [+] |
line wrap: on
line diff
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/arduino/D1Servo18/D1Servo18.cpp Sun Oct 09 12:25:21 2016 +0200 @@ -0,0 +1,20 @@ +#include "D1Servo18.h" + +D1Servo18::begin(uint8_t address = 0x0A) { + _address = address; + Wire.begin(); +} + +D1Servo18::write(uint8_t channel, uint16_t us) { + union { + byte bytes[2]; + uint16_t value; + } bytes2int; + + bytes2int.value = us; + Wire.beginTransmission(_address); + Wire.write(channel); + Wire.write(bytes2int.bytes[0]); + Wire.write(bytes2int.bytes[1]); + Wire.endTransmission(); +}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/arduino/D1Servo18/D1Servo18.h Sun Oct 09 12:25:21 2016 +0200 @@ -0,0 +1,13 @@ +#ifndef D1Servo18_h +#define D1Servo18_h + +#include <Wire.h> + +class D1Servo18 { + public: + D1Servo18(); + void begin(uint8_t address); + void write(uint8_t channel, uint16_t us); +} + +#endif
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/arduino/D1Servo18/examples/center/center.ino Sun Oct 09 12:25:21 2016 +0200 @@ -0,0 +1,16 @@ +/* + Centers servos on all 18 channels. +*/ +#include <D1Servo18.h> + +D1Servo18 servos = D1Servo18(); + +void setup() { + servos.begin(); + for (int channel = 0; channel < 18; ++channel) { + servos.write(channel, 1500); + } +} + +void loop() { +}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/arduino/D1Servo18/library.properties Sun Oct 09 12:25:21 2016 +0200 @@ -0,0 +1,9 @@ +name=D1Servo18 +version=1.0.0 +author=Radomir Dopieralski +maintainer= Radomir Dopieralski <devel@sheep.art.pl> +sentence=Driver for the D1 Mini 18-channel Servo Shield +paragraph= +category=Uncategorized +url=https://bitbucket.org/thesheep/d1mini-18ch-servo +architectures=*
