Motor Driver(L298N): 두 판 사이의 차이
잔글편집 요약 없음 |
잔글편집 요약 없음 |
||
| 1번째 줄: | 1번째 줄: | ||
{{#seo:|title= | {{#seo:|title=ArduWiki: Arduino L298N Motor Driver Guide|title_mode=append|keywords=Arduino, Computer Science, Maker Education, Performance Assessment, L298N Motor Driver, Arduino Project, Capstone Project, Arduino Example Code|description=How to control the L298N motor driver with Arduino (basic info, circuit, example code). Useful for computer science and maker classes.}} | ||
[[ | [[파일:L298N.jpg|center|class=coders100]] | ||
This module allows for control over the speed and direction of motors. It can operate two DC motors or one stepper motor. | This module allows for control over the speed and direction of motors. It can operate two DC motors or one stepper motor. | ||
2025년 3월 27일 (목) 18:23 기준 최신판

This module allows for control over the speed and direction of motors. It can operate two DC motors or one stepper motor.
Specifications
- Input Voltage: 9V ~ 12V
- Speed control via PWM signal
- Direction control with digital signals
Example Required Hardware
- Arduino board
- Jumper cables
- Power supply (9 ~ 12V, battery or adapter)
- DC motors
- L298N motor driver
Connection
| Arduino | L298N Motor Driver | DC motors | power supply |
| GND | GND | GND | |
| D9 | ENA | ||
| D8 | IN1 | ||
| D7 | IN2 | ||
| 9 ~ 12V | VCC | ||
| OUT1 | Connect | ||
| OUT2 | Connect |

Example Code
This example demonstrates gradually decreasing the motor's speed until it stops and then reversing direction.
const int IN1 = 8;
const int IN2 = 7;
const int ENA = 9;
void setup() {
pinMode(IN1, OUTPUT);
pinMode(IN2, OUTPUT);
digitalWrite(IN1, HIGH);
digitalWrite(IN2, LOW);
analogWrite(ENA, 255);
delay(2000);
analogWrite(ENA, 170);
delay(2000);
analogWrite(ENA, 85);
delay(2000);
analogWrite(ENA, 0);
delay(2000);
digitalWrite(IN1, LOW);
digitalWrite(IN2, HIGH);
analogWrite(ENA, 255);
delay(2000);
analogWrite(ENA, 170);
delay(2000);
analogWrite(ENA, 85);
delay(2000);
analogWrite(ENA, 0);
delay(2000);
}
void loop() {
delay(100);
}
Execution Result