Servo base, head;
int base_degree = 90;
int head_degree = 90;
void setup() {
base.attach(10); //把伺服馬達1的橘黃色信號線連接到D10
head.attach(11); //把伺服馬達2的橘黃色信號線連接到D11
}
void loop() {
int vrx = analogRead(A1);
int vry = analogRead(A2);
base_degree = map(vrx, 0, 1023, 0, 180); //搖桿VRx接到A1
head_degree = map(vry, 0, 1023, 0, 180); //搖桿VRy接到A2
base.write(base_degree);
head.write(head_degree);
}
留言
張貼留言