Page 6 of 16
Page 111
void setup() {
}
void loop() {
for (int d = 0; d < 256; d++) {
analogWrite(2, d);
delay(10);
}
}
Page 112
void setup() {
}
void loop() {
for (int d = 0; d < 256; d++) {
analogWrite(2, d * d * d / 255 / 255);
delay(10);
}
}
Page 114
uint8_t wave[256];
void setup() {
for (int i = 0; i < 256; i++) {
wave[i] = (uint8_t)((128.0 + sinf((float)i * 2.0 *
3.14159 / 255.0) * 128.0));
}
}
void loop() {
for (int i = 0; i < 256; i++) {
analogWrite(2, wave[i]);
delayMicroseconds(1000);
}
}
Page 121 The LEDC library is not currently supported by the Arduino NANO ESP32
void setup() {
ledcAttach(2, 1000, 8);
}
void loop() {
for (int d = 0; d < 256; d++) {
ledcWrite(2, d);
delay(10);
}
}
Page 121 The LEDC library is not currently supported by the Arduino NANO ESP32
void setup() {
ledcAttach(2, 1000, 8);
ledcAttach(4, 1000, 8);
}
void loop() {
for (int d = 0; d < 256; d++) {
ledcWrite(2, d);
ledcWrite(4, 255-d);
delay(10);
}
}
Page 123 The LEDC library is not currently supported by the Arduino NANO ESP32
uint8_t wave[256];
void setup() {
ledcAttach(2, 150000, 8);
for (int i = 0; i < 256; i++) {
wave[i] = (uint8_t)((128.0 +
sinf((float)i * 2.0 * 3.14159 / 255.0) * 128.0));
}
}
void loop() {
for (int i = 0; i < 256; i++) {
analogWrite(2, wave[i]);
delayMicroseconds(7);
}
}
Page 124
The LEDC library is not currently supported by the Arduino NANO ESP32
void setup() {
ledcAttach(2, 10000, 8);
ledcWriteTone(2, 262);
}
void loop() {
}
Page 125
The LEDC library is not currently supported by the Arduino NANO ESP32
void setup() {
ledcAttach(2, 1000, 8);
ledcFade(2, 0, 255, 1000);
}
void loop() {
}
Page 126
The LEDC library is not currently supported by the Arduino NANO ESP32
volatile int fading;
void ISR(void) {
fading = false;
}
void setup() {
ledcAttach(2, 1000, 8);
ledcFadeWithInterrupt(2, 0, 255, 1000, ISR);
fading = true;
}
void loop() {
if (!fading) {
delay(100);
ledcFadeWithInterrupt(2, 0, 255, 1000, ISR);
fading = true;
}
}
Page 127
The LEDC library is not currently supported by the Arduino NANO ESP32
#include "driver/ledc.h"
void setup() {
ledcAttach(2, 1000, 8);
ledcAttach(4, 1000, 8);
ledcWrite(2, 128);
ledcWrite(4, 128);
ledc_set_duty_with_hpoint(LEDC_LOW_SPEED_MODE,
LEDC_CHANNEL_1, 128,64);
}
void loop() {
}