CAFE

한국직업능력교육원

[Arduino 실습 45] 스탭모터(1단계 Arduino kit 제공(내장) Motor 돌리기)

작성자송명규|작성시간26.06.22|조회수5 목록 댓글 0




// Sys Lib

#include <stdio.h>

#include <string.h>

#include <stdlib.h>

 

// Arduino API

#include <Stepper.h>

 

// My Lib

#include <value.h>

#include <My_Arduino_GPIO_Lib_V1_8.h>

 

#include "stm.h"

 

const int step_reg = 2048; // 분해능

Stepper st_motor(step_reg, 8, 10, 9, 11); // a, b, /a, /b




void setup() {

  // put your setup code here, to run once:

  pinMode(ma, OUTPUT);

  pinMode(mb, OUTPUT);

  pinMode(ma_, OUTPUT);

  pinMode(mb_, OUTPUT);

 

  st_motor.setSpeed(18); //Speed

}

 

void loop() {

  // put your main code here, to run repeatedly:

  // 실습 1 = 기본돌리기 = 기존 라이브러리 사용  

  // cw

  st_motor.step(step_reg);

  delay(1000);

 

  // CCW

  st_motor.step(-step_reg);

  delay(1000);

}

//===========================================

 

#ifndef  __STM__

#define  __STM__

 

enum{

  ma = 8,  //a

  mb,  //9  b

  ma_, //10  a_

  mb_  //11  b_

}mt;

 

#define CW  1

#define CCw 2



#endif

다음검색
현재 게시글 추가 기능 열기

댓글

댓글 리스트
맨위로

카페 검색

카페 검색어 입력폼