BASIC4MCU | 질문게시판 | 답변 : 아두이노 서보모터 문의드립니다.
페이지 정보
작성자 master 작성일2019-05-01 13:58 조회4,189회 댓글0건
https://www.basic4mcu.com/bbs/board.php?bo_table=gac&wr_id=8413
본문
// MCU BASIC: https://www.basic4mcu.com// DateTime : 2019-05-01 오후 2:04:25// by Ok-Hyun Park//#include <Wire.h>#include <Adafruit_PWMServoDriver.h>Adafruit_PWMServoDriver pwm=Adafruit_PWMServoDriver();//#define SERVOMIN 150 // this is the 'minimum' pulse length count(out of 4096)#define SERVOMAX 600 // this is the 'maximum' pulse length count(out of 4096)//uint8_t servonum=0;//void setup(){Serial.begin(9600);Serial.println("8 channel Servo test!");pwm.begin();pwm.setPWMFreq(60); // Analog servos run at~60 Hz updatesdelay(10);}//void setServoPulse(uint8_t n,double pulse){double pulselength;pulselength=1000000; pulselength/=60; // 60 HzSerial.print(pulselength); Serial.println(" us per period");pulselength/=4096; // 12 bits of resolutionSerial.print(pulselength); Serial.println(" us per bit");pulse*=1000000; pulse/=pulselength; // convert to usSerial.println(pulse);pwm.setPWM(n,0,pulse);}//void loop(){Serial.println(servonum);//for(uint16_t pulselen=SERVOMIN; pulselen<SERVOMAX; pulselen++){pwm.setPWM(servonum,0,pulselen);delay(5);}//for(uint16_t pulselen=SERVOMAX; pulselen>SERVOMIN; pulselen--){pwm.setPWM(servonum,0,pulselen);delay(5);}//if(++servonum>7)servonum=0;}https://github.com/adafruit/Adafruit-PWM-Servo-Driver-Library/blob/master/examples/servo/servo.ino
이 예제로 돌려보세요
댓글 0
조회수 4,189등록된 댓글이 없습니다.