Replies: 1 comment
-
Not an issue with the library, so converting to discussion.
|
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
I am a novice
How to implement without library--
const uint16_t phase[2] = {510,0};
#define LED1 19
#define LED2 21
#define LED1_OFF digitalWrite(LED1, HIGH)//关灯1
#define LED1_ON digitalWrite(LED1, LOW)//开灯1
#define LED1_PWM digitalWrite(LED1, !digitalRead(LED1))//灯1闪烁
#define LED2_OFF digitalWrite(LED2, HIGH)//关灯2
#define LED2_ON digitalWrite(LED2, LOW)//开灯2
#define LED2_PWM digitalWrite(LED2, !digitalRead(LED2))//灯2闪烁
int freq1 = 39000; // 频率
int channel1 = 0; // 通道0,共16个通道,0
1520,duty最大取值为2^resolution-1int resolution1 = 11; // 分辨率,取值0
int freq2 = 39000; // 频率
int channel2 = 0; // 通道1,共16个通道,0
1520,duty最大取值为2^resolution-1int resolution2 = 11; // 分辨率,取值0
void setup()
{
ledcSetup(channel1, freq1, resolution1, .hpoint ); // 设置通道0
ledcSetup(channel2, freq2, resolution2 ); // 设置通道1
ledcAttachPin(LED1, channel1 ); // 将通道0与引脚19连接
ledcAttachPin(LED2, channel2 ); // 将通道1与引脚22连接
}
void loop()
{
// 逐渐变亮
int dutyCycle = 512;
{
ledcWrite(channel1, dutyCycle); // 输出PWM
ledcWrite(channel2, 1023 - dutyCycle); // 输出PWM
delay(5);
}
}
Beta Was this translation helpful? Give feedback.
All reactions