unsigned long t ;
void setup() {
// put your setup code here, to run once:
pinMode( 14 , INPUT ) ;
pinMode( 32 , INPUT ) ;
pinMode( 26 , OUTPUT ) ;
ledcSetup(0, 1000, 10);
ledcAttachPin(2, 0);
Serial.begin(9600) ;
}
void loop() {
int VR , LDR ;
VR = analogRead(14) ;
LDR = analogRead(32) ;
int V1 = map (VR,0,4095,0,255) ;
int V2 = map (LDR,0,4095,0,255) ;
ledcWrite(0, V1);
dacWrite (26, V2);
if(millis() >= t)
{
t = 500+millis();
timer(V1,V2) ;
}
}
void timer (int c , int x )
{
int V1 = map(c,0,255,0,100);
Serial.print("LED 1 = ");
Serial.print(V1) ;
Serial.println("%");
int V2 = map(x,0,255,0,100);
Serial.print("LED 2 = ");
Serial.print(V2) ;
Serial.println("%");
}