#define BITS 12
#define RLED 2
#define GLED 4
void setup() {
// put your setup code here, to run once:
Serial.begin(115200);
pinMode(RLED, OUTPUT);
pinMode(GLED, OUTPUT);
analogSetAttenuation(ADC_11db);
analogSetWidth(BITS);
ledcSetup(0, 5000, BITS);
ledcSetup(1, 5000, BITS);
ledcAttachPin(RLED, 0);
ledcAttachPin(GLED, 0);
}
void loop() {
// put your main code here, to run repeatedly:
uint16_t val = 1023 - analogRead(32);
uint16_t val2 = analogRead(32);
Serial.printf("val= %u\n", val);
Serial.printf("val2= %u\n", val2);
ledcWrite(1, val);
ledcWrite(0, val2);
delay(1000); // this speeds up the simulation
}