Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // Motor x-Axis
- int Red = 14; // Firing order for 4-Wire Micro-step Motor
- int Brown = 15; // First Brown coil
- int Yellow = 16; // Then Yellow coil and so on...
- int Orange = 10;
- // Motor y-axis
- // int Red = 2; // Firing order for 28BYJ-48 Stepper Motor
- // int Brown = 3; // First Brown coil
- // int Yellow = 4; // Then Yellow coil and so on...
- // int Orange = 5;
- long del = 500000; // 50.000 (+SPEED) -> 999.000 (-SPEED)// ABOVE this figure the motor will stall:/
- void setup() {
- pinMode(Red, OUTPUT);
- pinMode(Brown, OUTPUT);
- pinMode(Yellow, OUTPUT);
- pinMode(Orange, OUTPUT);
- for (int e = 0; e <= 5; e++) {
- //for (int i = 0; i <= 40; i++) {
- for (int i = 0; i <= 35; i++) {
- phaseOne();
- phaseTwo();
- phaseThree();
- phaseFour();
- }
- //for (int j = 0; j <= 40; j++) {
- for (int j = 0; j <= 35; j++) {
- phaseFour();
- phaseThree();
- phaseTwo();
- phaseOne();
- }
- }
- }
- void phaseOne() {
- digitalWrite(Red, LOW);
- digitalWrite(Brown, HIGH);
- digitalWrite(Yellow, HIGH);
- digitalWrite(Orange, LOW);
- delayMicroseconds(del);
- }
- void phaseTwo() {
- digitalWrite(Red, LOW);
- digitalWrite(Brown, HIGH);
- digitalWrite(Yellow, LOW);
- digitalWrite(Orange, HIGH);
- delayMicroseconds(del);
- }
- void phaseThree() {
- digitalWrite(Red, HIGH);
- digitalWrite(Brown, LOW);
- digitalWrite(Yellow, LOW);
- digitalWrite(Orange, HIGH);
- delayMicroseconds(del);
- }
- void phaseFour() {
- digitalWrite(Red, HIGH);
- digitalWrite(Brown, LOW);
- digitalWrite(Yellow, HIGH);
- digitalWrite(Orange, LOW);
- delayMicroseconds(del);
- }
- void motorOff() {
- digitalWrite(Red, LOW);
- digitalWrite(Brown, LOW);
- digitalWrite(Yellow, LOW);
- digitalWrite(Orange, LOW);
- }
- // the loop routine runs over and over again forever:
- void loop() {
- for (int e = 0; e <= 5; e++) {
- //for (int i = 0; i <= 40; i++) {
- for (int i = 0; i <= 35; i++) {
- phaseOne();
- phaseTwo();
- phaseThree();
- phaseFour();
- }
- //for (int j = 0; j <= 40; j++) {
- for (int j = 0; j <= 35; j++) {
- phaseFour();
- phaseThree();
- phaseTwo();
- phaseOne();
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement