답변:
예, Arduino의 아날로그 핀을 디지털 출력으로 사용할 수 있습니다.
이 내용은 핀 매핑 섹션 의 Arduino 입력 핀 설명서 에 설명되어 있습니다.
핀 매핑
A0 (아날로그 입력 0의 경우), A1 등을 사용하여 아날로그 핀을 디지털 핀과 동일하게 사용할 수 있습니다. 예를 들어, 코드는 아날로그 핀 0을 출력으로 설정하고 설정하는 방법입니다. 높음 :
pinMode (A0, OUTPUT);
digitalWrite (A0, HIGH);
디지털 쓰기에는 항상 아날로그 핀을 사용할 수 있습니다.
digitalRead()모든 핀에서 작동합니다. 수신 된 아날로그 값만 반올림하여 표시합니다. 경우 analogRead(A0)보다 크거나 같은지 (512), digitalRead(A0)다른 1, 0이 될 것이다.digitalWrite()0 또는 1 파라미터 수와, 모든 핀의 동작 digitalWrite(A0,0)과 동일 analogWrite(A0,0)하고, digitalWrite(A0,1)동일한이고analogWrite(A0,255)analogRead()아날로그 핀에서만 작동합니다. 0에서 1023 사이의 값을 사용할 수 있습니다.analogWrite()모든 아날로그 핀 및 모든 디지털 PWM 핀에서 작동합니다. 0에서 255 사이의 값을 제공 할 수 있습니다.아날로그 핀을 사용하면 아날로그 값을 읽고 쓸 수 있습니다. 기본적으로 0 또는 5의 전압 (디지털과 마찬가지로)을 제공하는 대신 0과 5 사이의 전압 범위 (입력 및 출력)를 제공 할 수 있습니다. 아날로그 출력 중 전압은 멀티 미터에서 관찰 된 전압 일뿐입니다. 실제로, 아날로그 핀은 0V 및 5V 신호의 펄스를 보내 아날로그를 보이는 출력 (PWM)을 얻습니다.
핀 수 : PWM 핀은 아날로그 출력에 사용될 수 있습니다. 핀이 부족하면 멀티플렉싱 을 사용하여 더 많은 것을 만들 수 있습니다. 다른 Arduino를 얻을 필요는 없습니다.
the Arduino (ATmega) will report HIGH if: a voltage greater than 3.0V is present at the pin (5V boards)이 게시물의 진술과 모순 If analogRead(A0) is greater than or equal to 512, digitalRead(A0) will be 1, else 0됩니다.
당신은 그것을 감당할 수있는, 그리고 당신이 정말로 스테퍼 작업을 확인하려면 아주 쉽게 확인 쉬운 스테퍼를 . 나는 매우 기뻤습니다.
로부터 예제 코드 페이지
http://www.sc-fa.com/blog/wp-content/uploads/2013/04/20130414-080645.jpg
Example 1: Basic Arduino setup
This is the most basic example you can have with an Arduino, an Easy Driver, and a stepper motor. Connect the motor's four wires to the Easy Driver (note the proper coil connections), connect a power supply of 12V is to the Power In pins, and connect the Arduino's GND, pin 8 and pin 9 to the Easy Driver.
Then load this sketch and run it on your Arduino or chipKIT:
void setup() {
pinMode(8, OUTPUT);
pinMode(9, OUTPUT);
digitalWrite(8, LOW);
digitalWrite(9, LOW);
}
void loop() {
digitalWrite(9, HIGH);
delay(1);
digitalWrite(9, LOW);
delay(1);
}
또한 같은 페이지에서 가속 / 감속을 사용하여 2 개의 easystepper 보드와 함께 2 개의 모터를 구동하는 예제 코드가 있습니다 . 081018.jpg
#include <AccelStepper.h>
// Define two steppers and the pins they will use
AccelStepper stepper1(1, 9, 8);
AccelStepper stepper2(1, 7, 6);
int pos1 = 3600;
int pos2 = 5678;
void setup()
{
stepper1.setMaxSpeed(3000);
stepper1.setAcceleration(1000);
stepper2.setMaxSpeed(2000);
stepper2.setAcceleration(800);
}
void loop()
{
if (stepper1.distanceToGo() == 0)
{
delay(500);
pos1 = -pos1;
stepper1.moveTo(pos1);
}
if (stepper2.distanceToGo() == 0)
{
delay(500);
pos2 = -pos2;
stepper2.moveTo(pos2);
}
stepper1.run();
stepper2.run();
}