Ahoj som zaciatocnik a mam taky problem a za svet ho neviem vyriesit snazim sa prist na to ako spustit krokovy motor tlacidlom tak aby vykonal to co ma a cakal na dalsie stlacenie tlacidla.
moj kod vyzera takto:
#include <Stepper.h>
int potPin = 2; // select the input pin for the potentiometer
int potenciometer = 0; // variable to store the value coming from the sensor
int in1Pin = 8;
int in2Pin = 9;
int in3Pin = 10;
int in4Pin = 11;
Stepper motor(512, in1Pin, in2Pin, in3Pin, in4Pin);
void setup()
{
pinMode(in1Pin, OUTPUT);
pinMode(in2Pin, OUTPUT);
pinMode(in3Pin, OUTPUT);
pinMode(in4Pin, OUTPUT);
motor.setSpeed(20);
Serial.begin(9600);
}
void loop()
{
potenciometer = analogRead(potPin); // read the value from the sensor
Serial.println(potenciometer); //vypise hodnotu potenciometer (polohu potenciometru)
int steps = -potenciometer;
motor.step(steps);
delay(500);
}
momentalne tam to tlacidlo nie je nakonfigurovane ale mal som ho tam a neplnilo vlastne ziaden ucel.. je pripojene na digitalnom pine 2. vobec si s tym neviem dat rady. ak by niekto vedel pomoct bol by som velmi vdacny 🙂