2015年2月8日 星期日

Arduino-步進馬達+A4988步進馬達驅動晶片

Sample :
http://www.geeetech.com/wiki/index.php/StepStick_A4988_Stepper_Driver_Module
http://nxtmarket.info/item/18857461634

Vedio :
https://www.youtube.com/watch?v=PrV-SLxIIFE
https://www.youtube.com/watch?v=lvaBb-rPepY
https://www.youtube.com/watch?v=xEcgYMPkykA


利用PWM腳位控制、9110模組控制

int dirPin = 8;
int stepperPin = 7;
void setup()
{
    pinMode(dirPin, OUTPUT);
    pinMode(stepperPin, OUTPUT);
}


void step(boolean dir,int steps) 
{
    digitalWrite(dirPin,dir);
    delay(50);
    for(int i=0;i<steps;i++){
        digitalWrite(stepperPin, HIGH);
        delayMicroseconds(800);
        digitalWrite(stepperPin, LOW);
        delayMicroseconds(800); 
        }
}

void loop()
{
    step(true,1600);
    delay(500);
    step(false,1600*5);
    delay(500);
}


void setup(){

    pinMode(4, OUTPUT);
    pinMode(5, OUTPUT);
    pinMode(6, OUTPUT);
    pinMode(7, OUTPUT);
}

void loop(){

    int i = 50;
  
    //順
    digitalWrite(4,HIGH);
    delay(i);
    digitalWrite(4,LOW);

    digitalWrite(5,HIGH);
    delay(i);
    digitalWrite(5,LOW);

/*
    //逆
    digitalWrite(6,HIGH);
    delay(i);
    digitalWrite(6,LOW);

    digitalWrite(7,HIGH);
    delay(i);
    digitalWrite(7,LOW);
  */
}



沒有留言:

張貼留言