Created
May 8, 2020 14:30
-
-
Save Miloune/ccdefcb53fbb5186968f921d66c3d80d to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Select "Arduino Nano" as card type | |
// Select "ATmega328P" or "ATmega328P (Old bootloader)" if Upload isn't working | |
// Select the COM port where you plug the Nano | |
// Include the Arduino Stepper.h library | |
#include <Stepper.h> | |
// Define number of steps per rotation | |
const int stepsPerRevolution = 2048; | |
// Wiring: | |
// Pin 8 to IN1 on the ULN2003 driver | |
// Pin 9 to IN2 on the ULN2003 driver | |
// Pin 10 to IN3 on the ULN2003 driver | |
// Pin 11 to IN4 on the ULN2003 driver | |
// Be carefull to the Pin order: | |
Stepper myStepper = Stepper(stepsPerRevolution, 8, 10, 9, 11); | |
// setup method, only executed once | |
void setup() { | |
// Set rpm speed; Max 14 | |
myStepper.setSpeed(8); | |
// Begin Serial communication at a baud rate of 9600: | |
Serial.begin(9600); | |
} | |
// your program in the loop method | |
void loop() { | |
// Step one revolution in one direction: | |
myStepper.step(stepsPerRevolution); // myStepper.step(-stepsPerRevolution); for reversing direction | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment