#include <Servo.h>
Servo myservo;
#define pot_circular 34
#define pot_slider 13
int pot1=0; //CREAR MI VARIABLE GUARDADAR DATOS POT
int pot2=0;
int volumen=0;
int posicion=0;
void setup() {
myservo.attach(12);
// put your setup code here, to run once:
Serial.begin(115200);
Serial.println("Hello, ESP32!");
pinMode(pot_circular, INPUT);
pinMode(pot_slider, INPUT);
}
void loop() {
// put your main code here, to run repeatedly:
pot1=analogRead(pot_circular);
Serial.print( "CIRCULAR: ");
Serial.println( pot1);
pot2=analogRead(pot_slider);
Serial.print( "SLIDER: ");
Serial.println(pot2);
//valores esp32 desde 0 a 4095 por los bit
//arduino maneja hasta 1024
volumen=map(pot1, 0,4095,0,10);
//mapea y convierte la lectura del pot
Serial.print("Nivel de volumen: ");
Serial.println(volumen);
myservo.write(90);
posicion=map(pot2, 0,4095,0,25);
//mapea y convierte la lectura del pot
Serial.print("Nivel de posición: ");
Serial.println(posicion);
delay(1000); // this speeds up the simulation
}