OS/Arduino
Arduino : 스탭모터(28BYJ48 + ULN2003) 제어
파란크리스마스
2019. 8. 18. 15:23
728x90
출처
소스
/*Example sketch to control a 28BYJ-48 stepper motor with ULN2003 driver board, and Arduino UNO. More info: https://www.makerguides.com */ // Include the Arduino Stepper Library: #include <Stepper.h> // 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 // Create stepper object called 'myStepper', note the pin order: Stepper myStepper = Stepper(stepsPerRevolution, 8, 10, 9, 11); void setup() { // Set the speed to 5 rpm: myStepper.setSpeed(5); // Initialize the serial port: Serial.begin(9600); } void loop() { // Step one revolution in one direction: Serial.println("clockwise"); myStepper.step(stepsPerRevolution); delay(500); // Step one revolution in the other direction: Serial.println("counterclockwise"); myStepper.step(-stepsPerRevolution); delay(500); }
실행 영상
728x90