Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #define Step 9 // Clk+
- #define Dir 8 // Cw+
- #define Bota3000 3 // botao
- #define Bota5000 4 // botao
- #define Bota8000 5 // botao
- unsigned int Qtde_Steps = 3000;
- unsigned int velocity = 100;
- //--------------------------------------------
- void setup()
- {
- Serial.begin(9600);
- pinMode(Bota3000, INPUT_PULLUP);
- pinMode(Bota5000, INPUT_PULLUP);
- pinMode(Bota8000, INPUT_PULLUP);
- pinMode(Dir, OUTPUT);
- pinMode(Step, OUTPUT);
- digitalWrite(Dir, LOW);
- digitalWrite(Step, LOW);
- digitalWrite(Dir, HIGH);
- }
- //---------------------------------------------
- void loop()
- {
- if (digitalRead(Bota3000) == LOW)
- {
- for ( int i = 0; i < Qtde_Steps ; i++)
- {
- digitalWrite(Step, HIGH);
- delayMicroseconds(velocity);
- digitalWrite(Step, LOW);
- delayMicroseconds(velocity);
- }
- }
- if (digitalRead(Bota5000) == LOW)
- {
- for ( int i = 0; i < (Qtde_Steps+2000) ; i++)
- {
- digitalWrite(Step, HIGH);
- delayMicroseconds(velocity);
- digitalWrite(Step, LOW);
- delayMicroseconds(velocity);
- }
- }
- if (digitalRead(Bota8000) == LOW)
- {
- for ( int i = 0; i < (Qtde_Steps+5000) ; i++)
- {
- digitalWrite(Step, HIGH);
- delayMicroseconds(velocity);
- digitalWrite(Step, LOW);
- delayMicroseconds(velocity);
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement