Coal Basin Servo: Text File
//Coal_Basin_Servo.ino Test or application file#include "Coal_Basin_Servo.h"Coal_Basin_Servo servo;void setup() { servo.begin( ); while(1) { servo.do_servo(0,LEFT); delay(2000); servo.do_servo(0,RIGHT); delay(2000); }}void loop() {}-----------------------------------------//Coal_Basin_Servo.cpp implementation file#include "Coal_Basin_Servo.h"#include <Wire.h>#include <Adafruit_PWMServoDriver.h>Adafruit_PWMServoDriver pwm(0x40);int _servo_timings [16] [2] ={ 100,400, //ch 0 100,200, //ch 1 100,200, //ch 2 100,200, //ch 3 100,200, //ch 4 100,200, //ch 5 100,200, //ch 6 100,200, //ch 7 100,200, //ch 8 100,200, //ch 9 100,200, //ch 10 100,200, //ch 11 100,200, //ch 12 100,200, //ch 13 100,200 //ch 15};Coal_Basin_Servo::Coal_Basin_Servo( ) { }void Coal_Basin_Servo::begin( ){ pwm.begin( ); pwm.setPWMFreq(50);}void Coal_Basin_Servo::do_servo(int ch, int dir){ pwm.setPWM(ch,0,_servo_timings[ch][dir]);}-----------------------------------------//Coal_Basin_Servo.h Header File#ifndef COAL_BASIN_SERVO_H#define COAL_BASIN_SERVO_H#include "Arduino.h"#define LEFT 0#define RIGHT 1class Coal_Basin_Servo { public: Coal_Basin_Servo( ); void begin( ); void do_servo(int ch, int dir); };#endif