Arduino Motor
Arduino Motor
Dùng chân có PWD.
1. DC Motor (Có thể quay đủ góc 360)
Linh kiện: POT-HG, MOTOR-DC.
Proteus:
Arduino IDE:
int motor = 9;
int bientro = A0;
void setup() {
// put your setup code here, to run once:
pinMode(motor, OUTPUT);
}
void loop() {
// put your main code here, to run repeatedly:
int reading = analogRead(bientro);
int tocdo = map(reading, 0, 1024, 0, 255);
analogWrite(motor, tocdo);
delay(100);
}
2. Servo (điều khiển được góc quay)
Library cài vào Arduino IDE: Servo.
Linh kiện: MOTOR-PWMSERVO.
Proteus:
Arduino IDE:
#include <Servo.h>
Servo myservo;
int bientro = A0;
int motor = 9;
void setup() {
// put your setup code here, to run once:
myservo.attach(motor);
}
void loop() {
// put your main code here, to run repeatedly:
int reading = analogRead(bientro);
int gocquay = map(reading, 0, 1024, 0, 180);
myservo.write(gocquay);
delay(100);
}
Mạch thực tế sẽ nối với transitor hoặc moffest rồi mới nối với Servo.
3. Động cơ bước đơn cực (có cả ưu điểm của 2 cái trên)
Linh kiện: 28-BYJ48.
Giới thiệu:
Cấu tạo các cuộn dây bên trong động cơ bước đơn cực:
Điều khiển cả bước:
Điều khiển nửa bước:
aaa