Quantcast
Channel: Arduino Forum - Latest topics
Viewing all articles
Browse latest Browse all 15287

Combina Encoder rotativo mas stpper

$
0
0

#include <Stepper.h>
#define <Steps 32>

volatile boolean tundetected;
volatile boolean rotatiodirection;

const int PinCLk = 2;
const int PinDT = 3;
const int PinSW = 4;

int RotaryPosition = 0;
int PrevPosition;
int Stepstotake;
Stepper small_Stepper(Steps 8, 9, 10, 11);

void isl(){
delay(400);
if(digitalRead(PinCLK));
rotationdirection = digitaRead(PinDT);
else
rotationdirection = digitalRead(PinDT);
TunDetected = true;
}

void setup(){
pinMode(PinCLK, INPUT);
pinMode(PinDT, INPUT);
pinMode(PinSW, INPUT);
digitalWrite(PinSW, HIGH);
attachInterrupt(0, isr, FALLING);
}
void loop(){
Small_Stepper = setSpeed(600);
if(!(digitalRead(PinSW))){
if(RotaryPosotion == 0){
else{
Small_Stepper.Stps(-(RotaryPosition*50);
RotaryPosition = 0;
}
}
if(TurnDetected){
PrevPosition = RotaryPosion;
if(Rotarydirectiono){
RotaryPosition = RotsaryPosition -1);
else
RotaryPosition = RotaryPosition +1);
turndetected = false
if(PrevPosition +1)==RotaryPosition);
stentotake = 50;
Small_Stepper.Steps(Steptotake);
}
if(RotaryPosition +1) == PrevPosition
Stepstotake =-50;
Small_Stepper.Steps(Stepstotake);
}
}

Ayuda desde ya muchas gracias

1 post - 1 participant

Read full topic


Viewing all articles
Browse latest Browse all 15287

Trending Articles