1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 | #include <Wire.h> #include <Adafruit_PWMServoDriver.h> #define nbPCAServo 16 int MIN_IMP [nbPCAServo] ={500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500}; int MAX_IMP [nbPCAServo] ={2500, 2500, 2500, 2500, 2500, 2500, 2500, 2500, 2500, 2500, 2500, 2500, 2500, 2500, 2500, 2500}; int MIN_ANG [nbPCAServo] ={0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}; int MAX_ANG [nbPCAServo] ={180, 180, 180, 180, 180, 180, 180, 180, 180, 180, 180, 180, 180, 180, 180, 180}; Adafruit_PWMServoDriver pca= Adafruit_PWMServoDriver(0x40); void setup(){ Serial.begin(9600); Serial.println(F("Initialize System")); pca.begin(); pca.setPWMFreq(60); // Analog servos run at ~60 Hz updates } void loop(){ pcaScenario(); } void pcaScenario(){ for (int i=0; i<nbPCAServo; i++) { Serial.print("Servo"); Serial.println(i); for(int pos=(MAX_IMP[i]+MIN_IMP[i])/2;pos<MAX_IMP[i];pos+=10){ pca.writeMicroseconds(i,pos);delay(10); } for(int pos=MAX_IMP[i];pos>MIN_IMP[i];pos-=10){ pca.writeMicroseconds(i,pos);delay(10); } for(int pos=MIN_IMP[i];pos<(MAX_IMP[i]+MIN_IMP[i])/2;pos+=10){ pca.writeMicroseconds(i,pos);delay(10); } pca.setPin(i,0,true); } } int jointToImp(double x,int i){ int imp=(x - MIN_ANG[i]) * (MAX_IMP[i]-MIN_IMP[i]) / (MAX_ANG[i]-MIN_ANG[i]) + MIN_IMP[i]; imp=max(imp,MIN_IMP[i]); imp=min(imp,MAX_IMP[i]); return imp; } | cs |
상품의 사용후기를 작성해주세요.
글읽기 권한이 없습니다.
"19세 미만의 미성년자"는 출입을 금합니다!
no | photo | title | write | date | hit | point |
---|---|---|---|---|---|---|
8 |
sg90에 사용했던 코드를 써도 동일하게 작동되나요? [1] |
오**** | 2022-11-01 | 673 | ||
7 |
혹시 서보모터 드라이버가 없어도 제어가 가능한가요? [1] |
잉**** | 2022-04-17 | 953 | ||
6 |
굳 |
이**** | 2021-07-05 | 525 | ||
5 |
이 서보모터 혹시 |
김**** | 2019-05-08 | 1141 | ||
4 |
잘 받았어요~ |
현**** | 2018-11-17 | 750 |
상품에 대해 궁금한 점을 해결해 드립니다.
글읽기 권한이 없습니다.
"19세 미만의 미성년자"는 출입을 금합니다!
no | category | title | write | date | hit |
---|---|---|---|---|---|
27 | 로봇팔의 그리퍼를 제어하고 싶어요 [1] | 재근 | 2021-11-19 | 68 | |
26 | 정품인가요? [1] | 맥스틸 | 2021-11-17 | 88 | |
25 | L298P 모터드라이버로는 사용 불가능 한가요? [1] | 1557 | 2021-11-15 | 90 | |
24 | 서보모터드라이버가 무조건 필요한가요?? [1] | tlzhsh2 | 2021-11-12 | 118 | |
23 | 해당 서보모터 라이브러리 파일 링크가 누락됬습니다. [2] | 79166170@n | 2021-10-12 | 83 |