inf sachen

This commit is contained in:
danielvici123
2024-12-02 11:49:11 +01:00
parent fc1eca66a4
commit c810f9541d
31 changed files with 2290 additions and 0 deletions

View File

@@ -0,0 +1,21 @@
// ----------------------------------------------------------------------------
// Constants.cpp
//
//
// Authors:
// Peter Polidoro peterpolidoro@gmail.com
// ----------------------------------------------------------------------------
#include "Constants.h"
namespace constants
{
const uint8_t device_address = 0x40;
const size_t output_enable_pin = 2;
const size_t loop_delay = 100;
const uint16_t frequency = 200;
const uint16_t time_increment = 100;
const uint8_t channel = 0;
}

View File

@@ -0,0 +1,24 @@
// ----------------------------------------------------------------------------
// Constants.h
//
//
// Authors:
// Peter Polidoro peterpolidoro@gmail.com
// ----------------------------------------------------------------------------
#ifndef CONSTANTS_H
#define CONSTANTS_H
#include <Arduino.h>
namespace constants
{
extern const uint8_t device_address;
extern const size_t output_enable_pin;
extern const size_t loop_delay;
extern const uint16_t frequency;
extern const uint16_t time_increment;
extern const uint8_t channel;
}
#endif

View File

@@ -0,0 +1,41 @@
#include <Arduino.h>
#include <PCA9685.h>
#include "Constants.h"
PCA9685 pca9685;
uint16_t time_min;
uint16_t time_max;
uint16_t off_time;
void setup()
{
pca9685.setupSingleDevice(Wire,constants::device_address);
pca9685.setupOutputEnablePin(constants::output_enable_pin);
pca9685.enableOutputs(constants::output_enable_pin);
pca9685.setOutputsNotInverted();
pca9685.setToFrequency(constants::frequency);
time_min = pca9685.getTimeMin();
time_max = pca9685.getTimeMax();
off_time = time_min;
pca9685.setChannelOnTime(constants::channel,time_min);
}
void loop()
{
if (off_time > time_max)
{
off_time = time_min;
}
pca9685.setChannelOffTime(constants::channel,off_time);
off_time += constants::time_increment;
delay(constants::loop_delay);
}