Browse Source

pca9685

tags/v0.1.0
Dominik Bartsch 3 years ago
parent
commit
c8cd28f519
2 changed files with 17 additions and 2 deletions
  1. 1
    1
      platformio.ini
  2. 16
    1
      src/main.cpp

+ 1
- 1
platformio.ini View File

lib_deps = lib_deps =


# The exact version # The exact version
ottowinter/PCA9685 16-Channel PWM Driver Module Library @ 1.2.9
ottowinter/PCA9685 16-Channel PWM Driver Module Library @ 1.2.9

+ 16
- 1
src/main.cpp View File



#include "wifi_credentials.h" #include "wifi_credentials.h"


#include <Wire.h>
#include "PCA9685.h"

const char* ssid = STASSID; const char* ssid = STASSID;
const char* password = STAPSK; const char* password = STAPSK;








PCA9685 pwmController;


void setup() { void setup() {
Serial.begin(115200); Serial.begin(115200);
WiFi.mode(WIFI_STA); WiFi.mode(WIFI_STA);
WiFi.begin(ssid, password); WiFi.begin(ssid, password);


Wire.begin(); // Wire must be started first
Wire.setClock(400000); // Supported baud rates are 100kHz, 400kHz, and 1000kHz

while (WiFi.waitForConnectResult() != WL_CONNECTED) { while (WiFi.waitForConnectResult() != WL_CONNECTED) {
Serial.println("Connection Failed! Rebooting..."); Serial.println("Connection Failed! Rebooting...");
delay(5000); delay(5000);
Serial.println(WiFi.localIP()); Serial.println(WiFi.localIP());


setup_webserver(); setup_webserver();

pwmController.resetDevices(); // Software resets all PCA9685 devices on Wire line

pwmController.init(B000000); // Address pins A5-A0 set to B000000
pwmController.setPWMFrequency(100); // Default is 200Hz, supports 24Hz to 1526Hz

pwmController.setChannelPWM(0, 128 << 4); // Set PWM to 128/255, but in 4096 land

Serial.println(pwmController.getChannelPWM(0)); // Should output 2048, which is 128 << 4
} }



Loading…
Cancel
Save