int Speed=10;
boolean Dr = FORWARD;
void setup(){
HCMotor.Init();
HCMotor.attach(0, STEPPER, CLK_PIN, DIR_PIN);
HCMotor.Steps(0,CONTINUOUS);
void loop() {
t=millis();
// 120ms 마다 실행 L1L2값 필요하므로 모터 여기에 넣음
if(t-t1>=120){ t3=t;
int L1= SensorValue[0];
int L2= SensorValue[1];
if(L1>=L2){
boolean Dr = FORWARD;
HCMotor.Direction(0, Dr); }
else{
boolean Dr = REVERSE;
HCMotor.Direction(0, Dr); }
if(digitalRead(LLIMIT_PIN) == LOW && Dr == REVERSE ){
int Speed = 10000;}
else if(digitalRead(RLIMIT_PIN) == LOW && Dr == FORWARD){
int Speed = 10000;}
else{
int Speed = 10;}
.............
초기 설정인 스피드 10으로만 움직이고... 좌우 전환은
if(L1>=L2){
boolean Dr = FORWARD;
HCMotor.Direction(0, Dr); }
else{
boolean Dr = REVERSE;
HCMotor.Direction(0, Dr); }
이걸로 잘되는데
if(digitalRead(LLIMIT_PIN) == LOW && Dr == REVERSE ){
int Speed = 10000;}
else if(digitalRead(RLIMIT_PIN) == LOW && Dr == FORWARD){
좌우 끝에서 움직임이 정지되지를 않네요 ㅠㅠㅠ
혹시분석해주실수있으실까요ㅠㅠ
댓글목록
등록된 댓글이 없습니다.
회원에게만 댓글 작성 권한이 있습니다.