const int adcPin = 4;
int valueADC;
int umbralBajo = 256;
int umbralAlto = 756;
void setup() {
// put your setup code here, to run once:
Serial.begin(115200);
Serial.println("Hello, ESP32!");
pinMode(14, OUTPUT);
pinMode(12, OUTPUT);
pinMode(13, OUTPUT);
//set the resolution to 12 bits (0-4095)
//analogReadResolution(12);
//set the resolution to 10 bits (0-1023)
analogReadResolution(10);
//digitalWrite(14, HIGH);
//digitalWrite(12, HIGH);
//digitalWrite(13, HIGH);
}
void loop()
{
valueADC = analogRead(adcPin);
if(valueADC <= umbralBajo)
{
digitalWrite(12, HIGH);
digitalWrite(14, LOW);
digitalWrite(13, LOW);
}
if(valueADC >= umbralAlto)
{
digitalWrite(13, HIGH);
digitalWrite(14, LOW);
digitalWrite(12, LOW);
}
if( (valueADC > umbralBajo) && (valueADC < umbralAlto))
{
digitalWrite(13, LOW);
digitalWrite(14, HIGH);
digitalWrite(12, LOW);
}
Serial.print("Valor Analogico ");
Serial.print(valueADC, DEC);
Serial.println("");
// put your main code here, to run repeatedly:
delay(500); // this speeds up the simulation
}