机械臂控制代码
机机械械臂臂控控制制代代码码 集团标准化小组[VVOPPT-JOPP28-JPPTL98-LOPPNN] include include include include “Wire.h“ include “WiiChuck.h“ Servo servo1;// create servo object to control a servo Servo servo2; Servo servo3; Servo servo4; // a maximum of eight servo objects can be created Servo servo5; Servo servo6; WiiChuck wii WiiChuck; int pos1,pos2,pos3,pos4,pos5,pos6,x,y,z,c; // variable to store the servo position void setup { // attaches the servo on pin 9 to the servo object servo1.attach8; servo2.attach9; servo3.attach10; servo4.attach11; servo5.attach12; servo6.attach13; pos1 60; pos2 50; pos3 100; pos4 100; pos5 90; pos6 90; servo1.writepos1; servo2.writepos2; servo3.writepos3; servo4.writepos4; servo5.writepos5; servo6.writepos6; wii.initWithPower; } void loop { iftrue wii.read { //读取手柄值 xwii.getJoyAxisX; ywii.getJoyAxisY; cwii.getButtonC; zwii.getButtonZ; } ifx255 servo1.writepos1; } } else ifx255 servo1.writepos1; delay40; ifpos1220 servo2.writepos2; delay 40; ifpos2160 { pos2160; servo2.writepos2; } } else ifx220 servo2.writepos2; delay40; ifpos2110 servo3.writepos3; } } else ifx110 servo3.writepos3; delay40; ifpos3160 { pos4160; servo4.writepos4; } } else ifx0 servo4.writepos4; delay40; ifpos4170 { pos5160; } } else ifx0 pos5 pos5-10; delay40; ifpos5240 pos6 pos610; delay 40; ifpos6120 { pos6119; } } else ifx0 pos6 pos6-10; delay40; ifpos645 { pos641; } } }