Điều khiển động cơ bước 5V- Giới thiệu Bài viết nguồn xem tại: Link Điều khiển động cơ bước 5V là bài học thứ 8 trong chuỗi bài tự học arduino. Ở bài học này, chúng ta sẽ cùng làm quen với loại động cơ bước đơn giản 28BYJ-48 và module ULN2003. Loại động cơ bước được sử dụng trong bài học này là loại động cơ bước 4 pha (2 pha được chia đôi ở mỗi pha ngay tại vị trí giữa) (gồm 5 dây). Một bước động cơ xoay 5.625 độ, để quay hết một vòng là 64 bước Thông số kỹ thuật Điện thế: 5V Số pha: 4 Tỉ lệ bánh răng: *64 Một bước tương đương 5.625 độ Tần số: 100Hz Điện trở trong 50 Ω±7%(25℃) Linh kiện chuẩn bị Arduino Uno R3 Dây bus đực cái Động cơ bước 5V và module ULN2003 Hướng dẫn chi tiết Để điều khiển động cơ bước 5V, ở video hướng dẫn sau đây chúng ta sẽ sử dụng thư viện Stepper.h được tích hợp sẵn trong arduino IDE để điều khiển. Các bạn chú ý theo dõi các bước thực hiện nhé Code mẫu arduino Các bạn có thể sử dụng code mẫu này để nạp cho arduino nhé. /* Stepper Motor Control – one revolution This program drives a unipolar or bipolar stepper motor. The motor is attached to digital pins 8 – 11 of the Arduino. The motor should revolve one revolution in one direction, then one revolution in the other direction. Created 11 Mar. 2007 Modified 30 Nov. 2009 by Tom Igoe */ #include const int stepsPerRevolution = 200; // change this to fit the number of steps per revolution // for your motor // initialize the stepper library on pins 8 through 11: Stepper myStepper(stepsPerRevolution, 8, 9, 10, 11); void setup() { // set the speed at 60 rpm: myStepper.setSpeed(60); // 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); }