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

아두위키 : Arduwiki
잔글편집 요약 없음
잔글편집 요약 없음
 
98번째 줄: 98번째 줄:


=== Execution Result ===
=== Execution Result ===
Please check the [https://blog.naver.com/gongzipsa/223168351657 link] for the operation video.
<div class="coders70">
<youtube> V2skKXsyCGE </youtube>
</div>

2024년 7월 10일 (수) 14:24 기준 최신판

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