BASIC4MCU | 질문게시판 | 아두이노 스텝모터 진동만옵니다..
페이지 정보
작성자 레고조합 작성일2018-06-11 03:25 조회5,773회 댓글0건
https://www.basic4mcu.com/bbs/board.php?bo_table=gac&wr_id=1698
첨부파일
본문
첨부파일에 코딩이 3가지 있습니다
아두이노우노 28byj48스테핑모터입니다.
1.5V전지 4개소켓을 연결했습니다
1번코딩으로 휴대폰 페어링 및 연결까지 되었습니다.
문제는2번입니다 모터가 진동만있고 정회전 역회전이 전혀 먹히지않습니다.
그래서 기본소스3번으로 문제가 무엇인지 돌려보았습니다. 단순180도 정회전 역회전인데 잘돌아갑니다. 무엇이 문제일까요..?
1번
#include <SoftwareSerial.h>
SoftwareSerial BTSerial(2, 3);
void setup()
{
Serial.begin(9600);
BTSerial.begin(9600);
}
void loop()
{
if (Serial.available())
{
BTSerial.write(Serial.read());
}
if (BTSerial.available())
{
Serial.write(BTSerial.read());
}
}
2번
#include <SoftwareSerial.h>
SoftwareSerial BTSerial(2,3);
//
#include <Stepper.h>
const int stepsPerRevolution=512;
Stepper myStepper(stepsPerRevolution,8,9,10,11);
//
void setup(){
myStepper.setSpeed(22);
BTSerial.begin(9600);
}
//
void loop(){
if(BTSerial.available()){
char c=BTSerial.read();
switch(c){
case 'e': myStepper.step( stepsPerRevolution); break;
case 'f': myStepper.step(-stepsPerRevolution); break;
}
}
}
3번
#include <Stepper.h>
const int steps_time = 2048;
Stepper steppermotor(steps_time,11,9,10,8);
void setup() {
steppermotor.setSpeed(17);
}
void loop() {
steppermotor.step(steps_time);
steppermotor.stop();
delay(3000);
steppermotor.step(-steps_time);
steppermotor.stop();
delay(3000);
}
댓글 0
조회수 5,773등록된 댓글이 없습니다.