test

Dependencies:   PCA9685PWM

Files at this revision

API Documentation at this revision

Comitter:
wrxavex
Date:
Wed Oct 18 15:23:49 2017 +0000
Commit message:
pca9685 for lpc1768

Changed in this revision

PCA9685PWM.lib Show annotated file Show diff for this revision Revisions of this file
main.cpp Show annotated file Show diff for this revision Revisions of this file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/PCA9685PWM.lib	Wed Oct 18 15:23:49 2017 +0000
@@ -0,0 +1,1 @@
+http://mbed.org/users/dreamworker/code/PCA9685PWM/#7f3c3ac6b20b
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/main.cpp	Wed Oct 18 15:23:49 2017 +0000
@@ -0,0 +1,42 @@
+#include"PCA9685.h"
+#include"mbed.h"
+
+
+
+PCA9685 pwm(p9,p10);
+ 
+void setServoPulse(uint8_t n, float pulse) {
+    pwm.setPWM(n, 0, pulse);
+}
+ 
+void initServoDriver() {
+    pwm.begin();
+    //pwm.setPrescale(121);     // set 20ms for generic servos
+    pwm.setPWMFreq(1000);
+    pwm.frequencyI2C(400000); //400kHz fast I2C comunication
+    
+}
+ 
+int main() {
+    
+ initServoDriver();
+
+    while(1){
+        for ( uint16_t i = 0; i<4095; i++){
+            pwm.setPWM(0, 0, i);
+        }
+        for ( uint16_t i = 4095; i>0; i--){
+            pwm.setPWM(0, 0, i);
+        }
+        
+        for ( uint16_t i = 0; i<4095; i++){
+            pwm.setPWM(1, 0, i);
+        }
+        for ( uint16_t i = 4095; i>0; i--){
+            pwm.setPWM(1, 0, i);
+        }
+    
+    
+    }  
+             
+}
\ No newline at end of file