Motor Driver(L298N): 두 판 사이의 차이

아두위키 : Arduwiki
잔글편집 요약 없음
잔글편집 요약 없음
 
1번째 줄: 1번째 줄:
{{#seo:|title=아두위키 : 아두이노 L298N 모터 드라이버 가이드|title_mode=append|keywords=아두이노, 정보과학, 메이커학습, 수행평가, L298N 모터 드라이버, 아두이노 작품, 캡스톤작품, 아두이노 예제코드|description=아두이노로 L298N 모터 드라이버를 제어하는 방법(기본정보, 회로, 예제 코드)을 소개합니다. 정보과학과 메이커수업에 활용가능합니다.}}
{{#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.}}
[[File:L298N.jpg|center|class=coders100]]
[[파일: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