티스토리 뷰
728x90
출처 : Tutorial - L298N Dual Motor Controller Module 2A and Arduino - Tronixlabs Australia
배선
L298N 스펙
- DC motor 1 "+" or stepper motor A+
- DC motor 1 "-" or stepper motor A-
- 12V jumper - remove this if using a supply voltage greater than 12V DC. This enables power to the onboard 5V regulator
- Connect your motor supply voltage here, maximum of 35V DC. Remove 12V jumper if >12V DC
- GND
- 5V output if 12V jumper in place, ideal for powering your Arduino (etc)
- DC motor 1 enable jumper. Leave this in place when using a stepper motor. Connect to PWM output for DC motor speed control.
- IN1
- IN2
- IN3
- IN4
- DC motor 2 enable jumper. Leave this in place when using a stepper motor. Connect to PWM output for DC motor speed control.
- DC motor 2 "+" or stepper motor B+
- DC motor 2 "-" or stepper motor B-
L298N 제어 소스
//모터A 컨트롤 int enA = 6; int IN1 = 7; int IN2 = 5; //모터B 컨트롤 int enB = 3; int IN3 = 4; int IN4 = 2; #define MOTER_SPEED 255 // MAX 255 void setup() { pinMode(enA, OUTPUT); pinMode(enB, OUTPUT); pinMode(IN1,OUTPUT); pinMode(IN2,OUTPUT); pinMode(IN3,OUTPUT); pinMode(IN4,OUTPUT); } void loop() { analogWrite(enA, MOTER_SPEED); analogWrite(enB, MOTER_SPEED); /* digitalWrite(enA,HIGH); digitalWrite(enB,HIGH); */ bothMotorStart(); // 전진 delay(3000); turnLeft(); // 왼쪽으로 턴 delay(3000); turnRight(); // 오른쪽으로 턴 delay(3000); motorA_Rotation(); // 왼쪽만 정방향 delay(3000); motorB_Rotation(); // 오른쪽만 정방향 delay(3000); motorA_Reverse(); // 왼쪽만 역방향 delay(3000); motorB_Reverse(); // 오른쪽만 역방향 delay(3000); stopAllMotor(); // 정지 delay(3000); } //모터A,B 정회전 void bothMotorStart() { digitalWrite(IN1,HIGH); digitalWrite(IN2,LOW); digitalWrite(IN3,HIGH); digitalWrite(IN4,LOW); } //모터A,B Stop void stopAllMotor() { digitalWrite(IN1,LOW); digitalWrite(IN2,LOW); digitalWrite(IN3,LOW); digitalWrite(IN4,LOW); } //모터A 역회전, 모터B 정회전 void turnLeft() { digitalWrite(IN1,LOW); digitalWrite(IN2,HIGH); digitalWrite(IN3,HIGH); digitalWrite(IN4,LOW); } //모터A 정회전, 모터B 역회전 void turnRight() { digitalWrite(IN1,HIGH); digitalWrite(IN2,LOW); digitalWrite(IN3,LOW); digitalWrite(IN4,HIGH); } //모터A 정회전, 모터B Stop void motorA_Rotation() { digitalWrite(IN1,HIGH); digitalWrite(IN2,LOW); digitalWrite(IN3,LOW); digitalWrite(IN4,LOW); } //모터A Stop, 모터B 정회전 void motorB_Rotation() { digitalWrite(IN1,LOW); digitalWrite(IN2,LOW); digitalWrite(IN3,HIGH); digitalWrite(IN4,LOW); } //모터A 역회전, 모터B Stop void motorA_Reverse() { digitalWrite(IN1,LOW); digitalWrite(IN2,HIGH); digitalWrite(IN3,LOW); digitalWrite(IN4,LOW); } //모터A Stop, 모터B 역회전 void motorB_Reverse() { digitalWrite(IN1,LOW); digitalWrite(IN2,LOW); digitalWrite(IN3,LOW); digitalWrite(IN4,HIGH); }
댓글
300x250
공지사항
최근에 올라온 글
최근에 달린 댓글
- Total
- Today
- Yesterday
TAG
- Java
- 동경
- oracle
- NDK
- ubuntu
- 송주경
- koba2010
- MySQL
- SAS
- Delphi
- ble
- Delphi Tip
- android
- flex
- Spring MVC
- 일본여행
- 레이싱모델 익스트림 포토 페스티벌
- Spring
- Mac
- 서울오토살롱
- BPI-M4
- JavaScript
- 전예희
- ffmpeg
- KOBA
- sas2009
- 지스타2007
- 튜닝쇼 2008
- Xcode
- Linux
일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
1 | 2 | 3 | 4 | 5 | 6 | 7 |
8 | 9 | 10 | 11 | 12 | 13 | 14 |
15 | 16 | 17 | 18 | 19 | 20 | 21 |
22 | 23 | 24 | 25 | 26 | 27 | 28 |
29 | 30 | 31 |
글 보관함