#include <Stepper.h>
#include <Ticker.h>
#define STEPS 200
Stepper stepper(STEPS, 32,33,25,26);
int pot;
int val;
int pot2;
int val2;
Ticker cambiador1;
Ticker cambiador2;
Ticker cambiador3;
int contador1=0;
int contador2=0;
int contador3=0;
void setup() {
Serial.begin(115200);
cambiador1.attach(0.1, funcion1);
cambiador2.attach(0.1, funcion2);
cambiador3.attach(0.3, funcion3);
pinMode(12, INPUT);
}
void funcion1(){
pot=analogRead(12);
val=pot*(60.0/4095.0);
}
void funcion2(){
stepper.setSpeed(val);
stepper.step(200);
stepper.setSpeed(val);
stepper.step(-200);
}
void funcion3(){
pot2=analogRead(12);
val2=pot*(60.0/4095.0);
Serial.print("val = ");
Serial.println(val2);
}
void loop() {
/*pot=analogRead(12);
val=pot*(60.0/4095.0);
stepper.setSpeed(val);
stepper.step(200);
delay(100);
stepper.setSpeed(val);
stepper.step(-200);
delay(100);
Serial.print("val = ");
Serial.println(val);
*/
}