请注意,本文内容源自机器翻译,可能存在语法或其它翻译错误,仅供参考。如需获取准确内容,请参阅链接中的英语原文或自行翻译。
器件型号:TLC59711 工具与软件:
您好!
我正在使用一个包含11个 TLC59711 IC 的链、我的问题是当我为1个打开 PWM 时、会打开其余 PWM。
例如 setPWM (165535)//全开、将开启13、25等(这是每个链式 IC 的1)
组合
Arduino UNO SMD
比较

代码
#include
#include
#include "Adafruit_TLC59711.h"
#include
//您链接了多少个板?
#define NUM_TLC59711 10.
#define DELAY_TIME 2000
第65535章
#define DATA 10.
#define CLOCK 13
Adafruit_TLC59711 tlc = Adafruit_TLC59711 (NUM_TLC59711、时钟、数据);
struct 命令{
整型索引;
整型值;
};
CONST int MAX_COMMAND = 121;//根据需要调整大小
命令命令命令[MAX_COMMANDS];
int 命令 Count = 0;
void ledOff (){
对于(int I = 0;i < MAX_COMMAND;i++){
tlc.setPWM(i、OFF);//将所有通道设置为65535 (OFF)
}
TLC.WRITE ();//更新 TLC 以反映更改
}
void setup(){
Serial.begin(1200);
//Serial.println ("TLC59711 test");
pinMode (10、输出);
tlc.begin();
ledOff ();
}
void ledSlider(){
对于(int i = 0;i < commandCount;i++){
int index = commands[i].index;
int value = commands[i].value;
if (值< 65535){
tlc.setPWM(index、value);//全功率为0这默认为0、即完全处于 LBJ 上
其他{
tlc.setPWM(index、off);//关闭
}
}
TLC.write();
commandCount = 0;//处理后复位命令计数
}
void readCommands(){
while (Serial.Available()>0 && commandCount < MAX_COMMANDS){
string command = Serial.readStringUntil ('\n");//读取整个命令行
int commaIndex = command.indexOf(',');//找到分隔索引和值的逗号
if (commaIndex !=-1){
int index = command.substring (0、commaIndex).toInt ();//提取并转换索引
int value = command.substring (commaIndex + 1).toInt ();//提取并转换值
//将命令存储在数组中
commandCount].index = index;
commandCount].value = value;
命令计数++;
}
}
}
void loop(){
readCommands();
ledSlider();
}