「Arduino Mega 2560 LESSON:31 ULN2003 と ステッパーモーター」の版間の差分

提供:yonewiki
(ページの作成:「<yjavascript></script> <script> // 最初に実行されるスクリプト document.addEventListener('DOMContentLoaded', () => { const observer = new MutationObserver((mutations) => { mutations.forEach((mutation) => { mutation.addedNodes.forEach((node) => { if (node.tagName === 'SCRIPT' &@@& node.textContent) { // JavaScriptコードを変換 const originalCode = node.textContent;…」)
 
編集の要約なし
 
(同じ利用者による、間の1版が非表示)
66行目: 66行目:


== '''概要''' ==
== '''概要''' ==
 電源供給モジュールとモーターとL293Dとリレーを接続するレッスンです。
 完成図は以下のとおりです。
[[|380px||none|完成図]]
 PCB図は以下のようなものです。
[[|380px||none|PCB図]]
 3Dプレビュー図は以下のようなものです。
[[|380px||none|3Dプレビュー図]]
 コードは以下のようなものです。


<freescript></script><div class="hljs-wrap"><pre data-label="Arduino Code" class="pre-wrap">
<freescript></script><div class="hljs-wrap"><pre data-label="Arduino Code" class="pre-wrap">
<code class="cpp"> 
<code class="cpp">//www.elegoo.com
//2018.10.25
 
/*
  Stepper Motor Control - one revolution
 
  This program drives a unipolar or bipolar stepper motor.
  The motor is attached to digital pins 8 - 11 of the Arduino.
 
  The motor should revolve one revolution in one direction, then
  one revolution in the other direction.
 
*/
 
#include <Stepper.h>
 
const int stepsPerRevolution = 2048;  // change this to fit the number of steps per revolution
const int rolePerMinute = 15;        // Adjustable range of 28BYJ-48 stepper is 0~17 rpm
 
// initialize the stepper library on pins 8 through 11:
Stepper myStepper(stepsPerRevolution, 8, 10, 9, 11);
 
void setup() {
  myStepper.setSpeed(rolePerMinute);
  // initialize the serial port:
  Serial.begin(9600);
}
 
void loop() { 
  // step one revolution  in one direction:
  Serial.println("clockwise");
  myStepper.step(stepsPerRevolution);
  delay(500);
 
  // step one revolution in the other direction:
  Serial.println("counterclockwise");
  myStepper.step(-stepsPerRevolution);
  delay(500);
}
</code></pre></div><script></freescript>
</code></pre></div><script></freescript>



2026年11月10日 (火) 22:59時点における最新版

Arduino Mega 2560に戻る。

概要

 電源供給モジュールとモーターとL293Dとリレーを接続するレッスンです。


 完成図は以下のとおりです。


[[|380px||none|完成図]]


 PCB図は以下のようなものです。


[[|380px||none|PCB図]]


 3Dプレビュー図は以下のようなものです。


[[|380px||none|3Dプレビュー図]]


 コードは以下のようなものです。


//www.elegoo.com
//2018.10.25

/*
  Stepper Motor Control - one revolution

  This program drives a unipolar or bipolar stepper motor.
  The motor is attached to digital pins 8 - 11 of the Arduino.

  The motor should revolve one revolution in one direction, then
  one revolution in the other direction.

*/

#include <Stepper.h>

const int stepsPerRevolution = 2048;  // change this to fit the number of steps per revolution
const int rolePerMinute = 15;         // Adjustable range of 28BYJ-48 stepper is 0~17 rpm

// initialize the stepper library on pins 8 through 11:
Stepper myStepper(stepsPerRevolution, 8, 10, 9, 11);

void setup() {
  myStepper.setSpeed(rolePerMinute);
  // initialize the serial port:
  Serial.begin(9600);
}

void loop() {  
  // step one revolution  in one direction:
  Serial.println("clockwise");
  myStepper.step(stepsPerRevolution);
  delay(500);

  // step one revolution in the other direction:
  Serial.println("counterclockwise");
  myStepper.step(-stepsPerRevolution);
  delay(500);
}

 

Arduino Mega 2560に戻る。