stepper_driver_test.ino 663 B

1234567891011121314151617181920212223242526272829
  1. // Pin definitions
  2. #define DATA_PIN D5 // DS
  3. #define CLOCK_PIN D6 // SH_CP
  4. #define LATCH_PIN D7 // ST_CP
  5. void setup() {
  6. // Initialize pins
  7. pinMode(DATA_PIN, OUTPUT);
  8. pinMode(CLOCK_PIN, OUTPUT);
  9. pinMode(LATCH_PIN, OUTPUT);
  10. }
  11. void writeStep(byte stepByte){
  12. shiftOut(DATA_PIN, CLOCK_PIN, MSBFIRST, stepByte);
  13. digitalWrite(LATCH_PIN, HIGH);
  14. digitalWrite(LATCH_PIN, LOW);
  15. delayMicroseconds(800); //780 min
  16. }
  17. void loop() {
  18. writeStep(0b00010001);
  19. writeStep(0b00110011);
  20. writeStep(0b00100010);
  21. writeStep(0b01100110);
  22. writeStep(0b01000100);
  23. writeStep(0b11001100);
  24. writeStep(0b10001000);
  25. writeStep(0b10011001);
  26. }