답변 : 압전센서 한개로 서보모터 두개 제어
페이지 정보
작성자 master 작성일18-12-10 16:58 조회3,597회 댓글0건본문
// MCU BASIC: https://www.basic4mcu.com
// DateTime : 2018-12-10 오후 5:04:11
// by Ok-Hyun Park
//
#include <Servo.h>
int sensor=A2;
int servoPin1=9;
int servoPin2=11;
Servo servo1;
Servo servo2;
//
int angle=0;
//
void setup(){
Serial.begin(9600);
servo1.attach(servoPin1);
servo2.attach(servoPin2);
}
//
void loop(){
int val=analogRead(sensor); //압전 센서의 데이터 받아오기
int angle=map(val,0,1023,0,180); //압력센서 값을 모터값으로 변환
servo1.write(angle); servo2.write(angle);
}
댓글 : 0
조회수 : 3,597
등록된 댓글이 없습니다.