background image

191

www.keyestudio.com

Connection Diagram

Test Code

*************************************************************************************************

#include <PS2X_lib.h>

PS2X ps2x; // create PS2 Controller Class

Содержание 4DOF

Страница 1: ...Keyestudio 4DOF Robot Arm Kit for Arduino DIY...

Страница 2: ...IDE 73 2 Installing Driver of V4 0 Board 74 3 Arduino IDE Setting 79 Project 2 4DOF Rotation and Pin Control 85 1 Joint Rotation and Servo Angle Settings 85 2 Pin Control 86 Project 3 Control the Robo...

Страница 3: ...trols the Robotic Arm 168 Project 5 PS2 controlled Robot Arm Extension 179 5 1 PS2 Joypad Key Test 179 5 2 PS2 Joypad Control 189 5 3 PS2 Controlling Posture Memory 205 5 4 PS2 Controls Posture Memory...

Страница 4: ...r routine life interesting Combined with STEM education DIY products can greatly cultivate teenagers imagination and creativity Therefore we Keyestudio R D group rolls out an amazing 4DOF mechanical a...

Страница 5: ...andle we provide joystick modules the second one is App and the third one is wireless PS2 joystick module not included in this kit I believe that you can t help getting down with this kit Next let s g...

Страница 6: ...io servo motor drive shield are as follows VIN voltage VIN DC 7 15V VIN current 5A Two channl 5V output 5V 3A PS2 interface compatible with Sony PS2 receiver can be plugged directly into the expansion...

Страница 7: ...kit and inside the packaging you will find all the parts and screws listed below Note Peel the plastic film off the board first when you install robotic arm No Item QTY Picture 1 Keyestudio V4 0 Contr...

Страница 8: ...5 4 Acrylic Handle 1 5 MeArm ABS Cylindrical Holder 1 6 180 Black Servo 4 7 BT 24 Module 1 8 Keyestudio Joystick Module 2 9 3D PS2 Joystick Cap 2...

Страница 9: ...driver 1 11 Galvanized Wrench 1 12 M3 6MM Round Head Screws 12 13 M3 10MM Round Head Screws 22 14 M3 14MM Flat Head Screws 2 15 M3 12MM Round Head Screws 12 16 M3 24 6MM Copper Pillar 4 17 M3 6mm 6m m...

Страница 10: ...xagon Nuts 24 20 M1 2x5MM Phillips Self tapping Screws 8 21 M2x5MM Phillips Self tapping Screws 10 22 M3 304 Stainless Steel Flat Washer 10 23 M2x8MM Phillips Self tapping Screws 2 24 M3 16MM Flat Hea...

Страница 11: ...8 26 Female Female 50CM Jumper Wire 10 27 Black 3 100MM Cable Ties 7 28 18650 2 Slot Battery Holder 1...

Страница 12: ...9 4 Assembly Guide 1 Install the base of the robotic arm Components Needed...

Страница 13: ...10...

Страница 14: ...11...

Страница 15: ...12...

Страница 16: ...13 The base is installed successfully...

Страница 17: ...14 2 Mount servos onto the base Components Needed...

Страница 18: ...15...

Страница 19: ...16 Assemble a servo left onto the left board...

Страница 20: ...17 Components Needed...

Страница 21: ...e the left servo Attach this left servo to G V and S 6 of servo motor driver shield upload the following code plug in power and press the rest button on the V4 0 board Then the left servo rotates to 1...

Страница 22: ...include Servo h Servo myservo create servo object to control a servo void setup Serial begin 9600 delay 1000 void loop myservo attach 6 Change pin to adjust one by one myservo write 180 Angle delay 10...

Страница 23: ...20...

Страница 24: ...21 a Fix the arm...

Страница 25: ...22...

Страница 26: ...23 Mount a servo right onto the right board Components Needed...

Страница 27: ...24 Note the breach direction of acrylic board...

Страница 28: ...vo to G V and S A0 of servo motor driver shield upload the following code plug in power and press the rest button on the V4 0 board Then the left servo rotates to 0 Set the servo to 0 include Servo h...

Страница 29: ...26 void setup Serial begin 9600 delay 1000 void loop myservo attach A0 Change pin to adjust one by one myservo write 0 Angle delay 1000...

Страница 30: ...27...

Страница 31: ...28...

Страница 32: ...29 Install the holder part...

Страница 33: ...30 Fix the left part and the mount part together...

Страница 34: ...31...

Страница 35: ...32 Fix the right part and the ABS holder together...

Страница 36: ...33 Note the direction of the ABS holder...

Страница 37: ...34...

Страница 38: ...35...

Страница 39: ...36...

Страница 40: ...37 Install the middle part...

Страница 41: ...38...

Страница 42: ...39...

Страница 43: ...40...

Страница 44: ...41...

Страница 45: ...42...

Страница 46: ...43...

Страница 47: ...44 Assemble the claw...

Страница 48: ...45...

Страница 49: ...46...

Страница 50: ...47...

Страница 51: ...48...

Страница 52: ...Initialize the servo Attach this left servo to G V and S 9 of servo motor driver shield upload the following code plug in power and press the rest button on the V4 0 board Then the left servo rotates...

Страница 53: ...50 Set the servo to 0 include Servo h Servo myservo create servo object to control a servo void setup Serial begin 9600 delay 1000 void loop...

Страница 54: ...51 myservo attach 9 Change pin to adjust one by one myservo write 0 Angle delay 1000 Mount gear wheels...

Страница 55: ...52...

Страница 56: ...53 Components Needed...

Страница 57: ...54...

Страница 58: ...itialize the servo Attach this left servo to G V and S A1 of sevro motor driver shield upload the following code plug in power and press the rest button on the V4 0 board Then the left servo rotates t...

Страница 59: ...56 Set the servo to 80 include Servo h Servo myservo create servo object to control a servo void setup Serial begin 9600 delay 1000 void loop...

Страница 60: ...57 myservo attach A1 Change pin to adjust one by one myservo write 80 Angle delay 1000 Install the robotic arm...

Страница 61: ...58...

Страница 62: ...59 Mount the control part...

Страница 63: ...60...

Страница 64: ...61 Wiring up Guide...

Страница 65: ...62...

Страница 66: ...63...

Страница 67: ...64...

Страница 68: ...65...

Страница 69: ...66 5 Robot Arm Projects Project 1 Install Arduino IDE and Driver Keyestudio V4 0 Development Board...

Страница 70: ...67 Keyestudio V4 0 development board is an Arduino uno comp atible board which is based on ATmega328P MCU and with a cp2102 Chip as a UART to USB converter...

Страница 71: ...n called the SPI serial peripheral interface and can be considered an extension of the output In fact slave the output devices to the SPI bus host When connecting to PC program the firmware to ATMEGA3...

Страница 72: ...nMode digitalWrite and digitalRead functions 4 GND GND 5 AREF Reference voltage 0 5V for analog inputs Used with analogReference Configures the reference voltage used for analog input i e the value us...

Страница 73: ...nd the label TX transmit When Arduino board communicates via serial port send the message TX led flashes 13 RX LED Onboard you can find the label RX receive When Arduino board communicates via serial...

Страница 74: ...Power Jack Arduino board can be supplied with an external power DC7 12V from the DC power jack 17 Microcontr oller Each Arduino board has its own microcontroller You can regard it as the brain of you...

Страница 75: ...the outputs for working with the 5V or 3 3V 19 RESET Header Connect an external button to reset the board The function is the same as reset button 20 Power Pin 3V3 A 3 3 volt supply generated by the o...

Страница 76: ...et control board we need to download Arduino IDE and driver firstly You could download Arduino IDE from the official website https www arduino cc click the SOFTWARE on the browse bar click DOWNLOADS t...

Страница 77: ...ortable installation 2 Installing Driver of V4 0 Board Let s install the driver of keyestudio V4 0 board The USB TTL chip on V4 0 board adopts CP2102 serial chip The driver program of this chip is inc...

Страница 78: ...ly please open the device manager of computer Right click Computer Properties Device Manager The yellow exclamation mark on the page implies an unsuccessful installation and you should double click th...

Страница 79: ...76 Click OK to enter the following page Click browse my computer for updated driver software...

Страница 80: ...77 Click Browse then search the driver of CP2102 and click Next There is a DRIVERS folder in Arduino software installed package open driver folder and check the driver of CP210X series chips...

Страница 81: ...78 When opening the device manager we will find the yellow exclamation mark disappear The driver of CP2102 is installed successfully...

Страница 82: ...79 3 Arduino IDE Setting...

Страница 83: ...80 Click icon and open Arduino IDE When downloading the sketch to the board you must select the correct name of Arduino board that matches the board connected to your computer As shown below...

Страница 84: ...81 Then select the correct COM port you can see the corresponding COM port after the driver is successfully installed...

Страница 85: ...82...

Страница 86: ...s or not B B Used to upload the sketch to your Arduino board C C Used to create shortcut window of a new sketch D D Used to directly open an example sketch E E Used to save the sketch F F Used to send...

Страница 87: ...Rotate toward the rightmost Rotate toward the leftmost Servo 2 right side Rocker arm connected to Servo 2 draws back stretch out Servo 3 left side Rocker arm connected to Servo 3 stretches out draw ba...

Страница 88: ...85 Project 2 4DOF Rotation and Pin Control 1 Joint Rotation and Servo Angle Settings...

Страница 89: ...o 1 baseplate A1 Servo 2 right side A0 Servo 3 left side 6 Servo 4 clamp claw 9 Right Joystick X A2 Right Joystick Y A5 Right Joystick Z B 7 Left Joystick X A3 Left Joystick Y A4 Left Joystick Z B 8 D...

Страница 90: ...the previous projects we set the square wave and angles of servos Now we use libraries of servos to control the angle of a servo We only need to put the servo folder in the libraries folder where the...

Страница 91: ...88 Test Code 1 include Servo h Servo myservo create servo object to control a servo void setup Serial begin 9600 delay 1000 void loop myservo attach A0 modify each pin to adjust...

Страница 92: ...oad the code plug in power and press the reset button Then the servo will automatically rotate to 0 Automatic Movement Description In the previous section you have learned to set the servo angle In fa...

Страница 93: ...Servo h Servo myservo1 create servo object to control a servo Servo myservo2 Servo myservo3 Servo myservo4 int pos1 80 pos2 60 pos3 130 pos4 0 void setup myservo1 attach A1 attaches the servo on pin...

Страница 94: ...yservo4 attach 9 myservo1 write pos1 delay 1000 myservo2 write pos2 myservo3 write pos3 myservo4 write pos4 delay 1500 void loop turn right for pos1 pos1 0 pos1 myservo1 write pos1 delay 5 delay 5ms u...

Страница 95: ...00 pos4 myservo4 write pos4 delay 1000 right servo rotates to 100 degrees for pos2 pos2 50 pos2 myservo2 write pos2 delay 5 left servo rotates to 5 degrees for pos3 pos3 50 pos3 myservo3 write pos3 de...

Страница 96: ...s4 myservo4 write pos4 delay 1000 left servo rotates to100 degrees rocker arm lifts for pos3 pos3 120 pos3 myservo3 write pos3 delay 5 delay 1000 turn to left for pos1 pos1 180 pos1 myservo1 write pos...

Страница 97: ...arm for pos3 pos3 50 pos3 myservo3 write pos3 delay 5 delay 1000 open the claw for pos4 pos4 100 pos4 myservo4 write pos4 delay 1000 lift up the arm for pos3 pos3 120 pos3 myservo3 write pos3 delay 5...

Страница 98: ...ress the reset button Then the robot arm will rotate to right stretch out the arm lower and enable claw then it will withdraw lift rotate to left stretch out lower and make claw open This series of ac...

Страница 99: ...down or 0 not press Check out the value printed on the serial monitor Connection Diagram Test Code 3 const int right_X A2 define the right X pin to A2 const int right_Y A5 define the right Y pin to A...

Страница 100: ...eft key to INPUT pinMode left_key INPUT Serial begin 9600 set the baud rate to 9600 void loop int x1 y1 z1 define the variable used to save the joystick value it reads int x2 y2 z2 x1 analogRead right...

Страница 101: ...print right_Y Serial println y1 DEC Serial print right_key Serial println z1 DEC Serial println right Serial print left_X Serial println x2 DEC Serial print left_Y Serial println y2 DEC Serial print l...

Страница 102: ...99 set the baud rate to 9600 you should see the analog value of the right Joystick pin X Y...

Страница 103: ...es to control 4DOF robot arm realize different motions At first set the boot posture The Joystick control is shown as below table Right Joystick Servo Left Joystick Servo X1 50 Servo 1 gradually reduc...

Страница 104: ...ally increases to 180 push the left joystick to the left the claw opens Y1 1000 Servo 2 gradually reduces to 0 that is lift up the robot upper arm Y2 1000 Servo 3 gradually reduces to 35 that is stret...

Страница 105: ...102 www keyestudio com...

Страница 106: ...e 4 include Servo h add the servo libraries Servo myservo1 create servo object to control a servo Servo myservo2 Servo myservo3 Servo myservo4 int pos1 80 pos2 60 pos3 130 pos4 0 define the variable o...

Страница 107: ...ine the right key pin to 7 that is the value of Z const int left_X A3 define the left X pin to A3 const int left_Y A4 define the left X pin to A4 const int left_key 8 define the left key pin to 8 that...

Страница 108: ...A1 myservo2 attach A0 set the control pin of servo 2 to A0 myservo3 attach 6 set the control pin of servo 3 to D6 myservo4 attach 9 set the control pin of servo 4 to D9 x1 analogRead right_X read the...

Страница 109: ...obi lower arm dabi claw void zhuazi claw if x2 50 if push the left joystick to the right pos4 pos4 2 current angle of servo 4 subtracts 2 change the value you subtract thus change the closed speed of...

Страница 110: ...p subtraction when reduce to 2 if x2 1000 if push the left joystick to the left pos4 pos4 8 current angle of servo 4 plus 8 change the value you plus thus change the open speed of claw Serial println...

Страница 111: ...s 1 myservo1 write pos1 servo 1 operates the motion the arm turns right delay 5 if pos1 1 limit the angle when turn right pos1 1 if x1 1000 if push the right joystick to the let pos1 pos1 1 pos1 plus...

Страница 112: ...t joystick upward pos2 pos2 1 myservo2 write pos2 the upper arm will lift delay 5 if pos2 0 limit the lifting angle pos2 0 if y1 50 if push the right joystick downward pos2 pos2 1 myservo2 write pos2...

Страница 113: ...ower arm void dabi if y2 50 if push the left joystick upward pos3 pos3 1 myservo3 write pos3 lower arm will stretch out delay 5 if pos3 180 limit the stretched angle pos3 180 if y2 1000 if push the le...

Страница 114: ...tack the shield onto it and wire them up then 4DOF robot arm will keep the initial position You can control the robot arm with Joysticks 3 4 Add Memory Function Memorize One Posture Description In the...

Страница 115: ...variables for saving the angle value of 4 servos use the Joystick to control a posture Press the key Z1 of right Joystick to save the angle value of 4 servos press the key Z2 of left Joystick to make...

Страница 116: ...servo1 create servo object to control a servo Servo myservo2 Servo myservo3 Servo myservo4 int pos1 80 pos2 60 pos3 130 pos4 0 define the variable of 4 servo angle and assign the initial value that is...

Страница 117: ...define the left X pin to A3 const int left_Y A4 define the left Y pin to A4 const int left_key 8 define the left key pin to 8 that is Z value int x1 y1 z1 define the variable used to save the joystick...

Страница 118: ...myservo3 attach 6 set the control pin of servo 3 to D6 myservo4 attach 9 set the control pin of servo 4 to D9 x1 analogRead right_X read the right X value y1 analogRead right_Y read the right Y value...

Страница 119: ...the angle value of each servo s2 myservo2 read s3 myservo3 read s4 myservo4 read if z2 1 if the left key is pressed delay 10 if z2 1 pos1 myservo1 read record the angle value of 4 servos in current p...

Страница 120: ...y for 5ms controlling the rotation speed of servo else if angle of servo 1 is greater than the value stored in array 1 while pos1 s1 while loop rotate the servo to the position of the value stored in...

Страница 121: ...118 www keyestudio com while pos2 s2 myservo2 write pos2 pos2 delay 5 else while pos2 s2 myservo2 write pos2 pos2 delay 5 the explanation is the same as servo 1 if pos3 s3 while pos3 s3...

Страница 122: ...119 www keyestudio com myservo3 write pos3 pos3 delay 5 else while pos3 s3 myservo3 write pos3 pos3 delay 5 the explanation is the same as servo 1 if pos4 s4 while pos4 s4 myservo4 write pos4...

Страница 123: ...120 www keyestudio com pos4 delay 5 else while pos4 s4 myservo4 write pos4 pos4 delay 5 claw zhuazi turn zhuandong upper arm...

Страница 124: ...subtracts 2 change the value you subtract thus change the closed speed of claw Serial println pos4 myservo4 write pos4 servo 4 operates the action claw is gradually closed delay 5 if pos4 2 if pos4 v...

Страница 125: ...e the open speed of claw Serial println pos4 myservo4 write pos4 servo 4 operates the motion the claw gradually opens delay 5 if pos4 90 limit the largest angle when open pos4 90 turn void zhuandong i...

Страница 126: ...n right pos1 1 if x1 1000 if push the right joystick to the left pos1 pos1 1 pos1 plus 1 myservo1 write pos1 robot arm turns left delay 5 if pos1 180 limit the angle when turn left pos1 180 upper arm...

Страница 127: ...rite pos2 the upper arm will lift delay 5 if pos2 0 limit the lifting angle pos2 0 if y1 50 if push the right joystick downward pos2 pos2 1 myservo2 write pos2 the upper arm will go down delay 5 if po...

Страница 128: ...pward pos3 pos3 1 myservo3 write pos3 the lower arm will stretch out delay 5 if pos3 35 limit the stretched angle pos3 35 if y2 50 if push the left joystick downward pos3 pos3 1 myservo3 write pos3 th...

Страница 129: ...the key Z2 of left Joystick to operate a servo posture saved in the variable Memorize Multiple Postures Description In the previous section we have set the angle of 4 servos to make the robot arm rem...

Страница 130: ...127 www keyestudio com That is make robot arm memorize a group of actions and you can set the memorizing speed in the code Connection Diagram...

Страница 131: ...myservo1 create servo object to control a servo Servo myservo2 Servo myservo3 Servo myservo4 int pos1 80 pos2 60 pos3 130 pos4 0 define the variable of 4 servo angle and assign the initial value that...

Страница 132: ...pin to 8 that is Z value int x1 y1 z1 define the variable used to save the joystick value int x2 y2 z2 int s1 s2 s3 s4 int jiyi1 10 define 4 array separately used to save the angle of four servo int...

Страница 133: ...set baud rate to 9600 void loop myservo1 attach A1 set the control pin of servo 1 to A1 myservo2 attach A0 set the control pin of servo 2 to A0 myservo3 attach 6 set the control pin of servo 3 to D6 m...

Страница 134: ...uce the speed overall if z1 1 if the right joystick key is pressed delay 10 delay for eliminating shake if z1 1 judge again if the right key is pressed s1 myservo1 read read the angle value of each se...

Страница 135: ...t value of i to j delay 100 Serial println i on the serial monitor print out the value i if z2 1 if the left joystick key is pressed delay 10 if z2 1 judge again if the left key is pressed i 0 assign...

Страница 136: ...ray myservo1 write pos1 servo 1 performs the action delay 5 delay 5ms controlling the servo rotating speed pos1 pos1 plus 1 Serial println pos1 else if the current servo 1 angle is greater than the va...

Страница 137: ...com the explanation is the same as the previous servo if pos2 jiyi2 k while pos2 jiyi2 k myservo2 write pos2 delay 5 pos2 Serial println pos1 else while pos2 jiyi2 k myservo2 write pos2 delay 5 pos2 S...

Страница 138: ...eyestudio com the explanation is the same as the previous servo if pos3 jiyi3 k while pos3 jiyi3 k myservo3 write pos3 delay 5 pos3 Serial println pos1 else while pos3 jiyi3 k myservo3 write pos3 dela...

Страница 139: ...io com Serial println pos1 the explanation is the same as the previous servo if pos4 jiyi4 k while pos4 jiyi4 k myservo4 write pos4 delay 5 pos4 Serial println pos1 else while pos4 jiyi4 k myservo4 wr...

Страница 140: ...137 www keyestudio com pos4 Serial println pos1 claw zhuazi turn zhuandong upper arm xiaobi lower arm dabi claw void zhuazi...

Страница 141: ...osed delay 5 if pos4 2 if pos4 value subtracts to 2 the claw in 37 degrees we have tested is closed should change the value based on the fact pos4 2 stop subtraction when reduce to 2 if x2 1000 if pus...

Страница 142: ...to the right pos1 pos1 1 pos1 subtracts 1 myservo1 write pos1 servo 1 operates the motion and robot arm turns right delay 5 if pos1 1 limit the angle when turn right pos1 1 if x1 1000 if push the righ...

Страница 143: ...y 5 if pos1 180 limit the angle when turn left pos1 180 upper arm void xiaobi if y1 1000 if push the right joystick upward pos2 pos2 1 myservo2 write pos2 the upper arm will lift delay 5 if pos2 0 lim...

Страница 144: ...1 myservo2 write pos2 the upper arm will go down delay 5 if pos2 180 limit the declining angle pos2 180 lower arm void dabi if y2 1000 if push the left joystick upward pos3 pos3 1 myservo3 write pos3...

Страница 145: ...ower arm will draw back delay 5 if pos3 180 limit the retracted angle pos3 180 Test Result Wire it up stack the shield onto V4 0 upload the code Powered on press the key Z1 of right Joystick to save t...

Страница 146: ...xt you can press the left button to perform actions saved Memorize Several Postures And Loop Description In the previous section we have introduced how to make 4DOF robot arm to memorize and perform a...

Страница 147: ...144 www keyestudio com...

Страница 148: ...myservo4 int pos1 80 pos2 60 pos3 130 pos4 0 define the variable of 4 servo angle and assign the initial value that is the boot posture angle value const int right_X A2 define the right X pin to A2 c...

Страница 149: ...can save angle data of 0 20 servo int jiyi3 20 if need to save more data just change the number 20 to be more larger number int jiyi4 20 int i 0 for loop int j 0 save the last value of i void setup b...

Страница 150: ...gRead left_Y read the left Y value z2 digitalRead left_key read the left Z value delay 5 delay used to reduce the joystick value read that is reduce the whole speed if z1 1 if the joystick right key i...

Страница 151: ...0ms Serial println i print out the value i if z2 1 if the left joystick key is pressed delay 10 delay for eliminating shake if z2 1 judge again if the left key is pressed pos1 myservo1 read memorize t...

Страница 152: ...println pos1 else if the current servo 1 angle is greater than the value stored in array 1 while pos1 jiyi1 k while loop make servo turn to the position of value stored in the array myservo1 write po...

Страница 153: ...pos1 else while pos2 jiyi2 k myservo2 write pos2 delay 5 pos2 Serial println pos1 the explanation is the same as the previous servo if pos3 jiyi3 k while pos3 jiyi3 k myservo3 write pos3 delay 5 pos3...

Страница 154: ...lay 5 pos3 Serial println pos1 the explanation is the same as the previous servo if pos4 jiyi4 k while pos4 jiyi4 k myservo4 write pos4 delay 5 pos4 Serial println pos1 else while pos4 jiyi4 k myservo...

Страница 155: ...he key z1 is pressed pos1 jiyi1 j 1 assign the last angle value saved in array to pos pos2 jiyi2 j 1 for exiting the loop still access to joystick control pos3 jiyi3 j 1 pos4 jiyi4 j 1 i 0 assign i as...

Страница 156: ...is gradually closed delay 5 if pos4 2 if pos4 value subtracts to 2 the claw in 37 degrees we have tested is closed should change the value based on the fact pos4 2 stop subtraction when reduce to 2 i...

Страница 157: ...subtracts 1 myservo1 write pos1 servo 1 performs the action the robot arm turns right delay 5 if pos1 1 limit the right turning angle pos1 1 if x1 1000 if push the right joystick to the left pos1 pos1...

Страница 158: ...stick upward pos2 pos2 1 myservo2 write pos2 the robot arm will lift delay 5 if pos2 0 limit the lifting angle pos2 0 if y1 50 if push the right joystick downward pos2 pos2 1 myservo2 write pos2 the r...

Страница 159: ...ward pos3 pos3 1 myservo3 write pos3 the lower arm will stretch out delay 5 if pos3 35 limit the stretched angle pos3 35 if y2 50 if push the right joystick downward pos3 pos3 1 myservo3 write pos3 th...

Страница 160: ...ion Press the key Z1 again start to memorize the posture after that press the key Z2 to loop the memorized actions Move the thumbsticks and press the button of right thumbstick then move them and pres...

Страница 161: ...id IOS system Specification Bluetooth protocol Bluetooth Specification V5 1 BLE Working distance In an open environment achieve 40m ultra long distance communication Operating frequency 2 4GHz ISM ban...

Страница 162: ...ature 10 to 65 degrees Celsius Bluetooth Control Key Test Description Next we are going to introduce the use method for BT 24 Bluetooth module To easily use the BT 24 Bluetooth module to control the r...

Страница 163: ...in the experiment we will test each key to get the corresponding value Installation Steps for Android system APP for Android mobile Enter google play search keyes arm https play google com store apps...

Страница 164: ...161 www keyestudio com 1 Download and install the interface shown below 2 Upload code and power on Led of Bluetooth module blinks Start Bluetooth and open App to click CONNECT to connect...

Страница 165: ...162 www keyestudio com 3 Upload code on control board after power on LED blinks on Bluetooth module Start Bluetooth and open App to click connect Bluetooth is connected...

Страница 166: ...163 www keyestudio com For IOS system 2 Open App Store 3 Search keyes arm on APP Store then click downlaod...

Страница 167: ...Special Note Remove the Bluetooth module please when uploading the Test Code Otherwise the program will fail to upload After uploading the Test Code then connect the Bluetooth and Bluetooth module to...

Страница 168: ...165 www keyestudio com Test Code void setup Serial begin 9600 set the serial baud rate to 9600...

Страница 169: ...etooth if Serial available if receive the value val Serial read assign the value read to val Serial println val After connecting Bluetooth module open serial port monitor to set baud rate to 9600 Pres...

Страница 170: ...functions of control keys Connect APP to bt 24 Bluetooth module Turn off Bluetooth Press to send F Release to send S Left servo goes front Left servo stops motion Press to send L Release to send S Cl...

Страница 171: ...Right servo stretches out Right servo stops motion Press to send l Release to send S The base servo turns left Base servo stops Mode 2 Press to send r Release to send S Base Servo turns right Base Ser...

Страница 172: ...is experiment we ll control 4DOF robotic arm movement via APP Note After uploading test code successfully unplug the USB data cable and power up via external power supply and control 4 DOF robot arm m...

Страница 173: ...170 www keyestudio com...

Страница 174: ...braries Servo myservo1 create servo object to control a servo Servo myservo2 Servo myservo3 Servo myservo4 int pos1 80 pos2 60 pos3 130 pos4 0 define the variable of 4 servo angle and assign the initi...

Страница 175: ...pos4 delay 1500 Serial begin 9600 set the baud rate to 9600 void loop myservo1 attach A1 set the control pin of servo 1 to A1 myservo2 attach A0 set the control pin of servo 2 to A0 myservo3 attach 6...

Страница 176: ...rintln val switch val case L T_left break execute the corresponding function when receive the value case R T_right break case f RF break case b rb break case F ZK break case B ZB break case l LF break...

Страница 177: ...ly pressed button so the command of pressing the button will be repeated case L T_left break execute the corresponding function when receive the value case R T_right break case f RF break case b rb br...

Страница 178: ...175 www keyestudio com myservo1 write pos1 delay 5 if pos1 180 pos1 180 turn right void T_right pos1 pos1 1 myservo1 write pos1 delay 5 if pos1 1 pos1 1 open the claw void ZK...

Страница 179: ...6 www keyestudio com pos4 pos4 2 Serial println pos4 myservo4 write pos4 delay 5 if pos4 2 pos4 0 close the claw void ZB pos4 pos4 8 Serial println pos4 myservo4 write pos4 delay 5 if pos4 108 pos4 10...

Страница 180: ...ww keyestudio com the upper arm will lift up void RF pos2 pos2 1 myservo2 write pos2 delay 5 if pos2 0 pos2 0 the upper arm will go down void rb pos2 pos2 1 myservo2 write pos2 delay 5 if pos2 180 pos...

Страница 181: ...ww keyestudio com the lower arm will stretch out void lb pos3 pos3 1 myservo3 write pos3 delay 5 if pos3 180 pos3 180 the lower arm will draw back void LF pos3 pos3 1 myservo3 write pos3 delay 5 if po...

Страница 182: ...te pos2 myservo3 write pos3 myservo4 write pos4 Test Result Upload the code connect it up and power on after connecting the Bluetooth APP press the key to control the robot arm do commanded motions Pr...

Страница 183: ...e PS2 Joypad After connecting the Joypad should upload the test program on Arduino IDE But before testing should place the PS2X_lib folder inside the libraries folder of Arduino IDE directory Uploadin...

Страница 184: ...Pressures Rumble check for error if error 0 Serial println Found Controller configured successful Serial println Try out all the buttons X will vibrate the controller faster as you press harder Serial...

Страница 185: ...g Visit www billporter info for troubleshooting tips else if error 3 Serial println Controller refusing to enter Pressures mode may not support it Serial print ps2x Analog 1 HEX type ps2x readType swi...

Страница 186: ...alues ps2x read_gamepad small motor on off larger motor strenght from 0 255 if you don t enable the rumble use ps2x read_gamepad with no values you should call this at least once a second if error 1 s...

Страница 187: ...essed if ps2x ButtonPressed BLUE_FRET Serial println Blue Fret Pressed if ps2x ButtonPressed ORANGE_FRET Serial println Orange Fret Pressed if ps2x ButtonPressed STAR_POWER Serial println Star Power C...

Страница 188: ...IF TRUE Serial print Wammy Bar Position Serial println ps2x Analog WHAMMY_BAR DEC else DualShock Controller ps2x read_gamepad false vibrate read controller and set large motor to spin at vibrate speed...

Страница 189: ...int Right held this hard Serial println ps2x Analog PSAB_PAD_RIGHT DEC if ps2x Button PSB_PAD_LEFT Serial print LEFT held this hard Serial println ps2x Analog PSAB_PAD_LEFT DEC if ps2x Button PSB_PAD_...

Страница 190: ...s2x Button PSB_L3 Serial println L3 pressed if ps2x Button PSB_R3 Serial println R3 pressed if ps2x Button PSB_L2 Serial println L2 pressed if ps2x Button PSB_R2 Serial println R2 pressed if ps2x Butt...

Страница 191: ...e TRUE if button was JUST pressed OR released Serial println X just changed if ps2x Button PSB_L1 ps2x Button PSB_R1 print stick values if either is TRUE Serial print Stick Values Serial print ps2x An...

Страница 192: ...and set the baud rate to 57600 When press down the key or push the rocker you should see the corresponding character showed on the monitor 5 2 PS2 Joypad Control Description In the previous section w...

Страница 193: ...law Push to the right side Rotate to right Push to the right side close Push to the left side Rotate to left Push to the left side open Push forward The small arm will lift Push forward The large arm...

Страница 194: ...191 www keyestudio com Connection Diagram Test Code include PS2X_lib h PS2X ps2x create PS2 Controller Class...

Страница 195: ...ad pins again after connecting the controller int error 0 byte vibrate 0 include Servo h add the servo libraries Servo myservo1 create servo object to control a servo Servo myservo2 Servo myservo3 Ser...

Страница 196: ...Serial println Found Controller configured successful Serial println Try out all the buttons X will vibrate the controller faster as you press harder Serial println holding L1 or R1 will print out the...

Страница 197: ...rter info for troubleshooting tips Serial print ps2x Analog 1 HEX ps2x enableRumble enable rumble vibration motors ps2x enablePressures enable reading the pressure values from the buttons void loop Yo...

Страница 198: ...e control pin of servo 2 to A0 myservo3 attach 6 set the control pin of servo 3 to D6 myservo4 attach 9 set the control pin of servo 4 to D9 if error 0 return ps2x read_gamepad false vibrate read cont...

Страница 199: ...2x Button PSB_PAD_RIGHT Serial print Right held this hard Serial println ps2x Analog PSAB_PAD_RIGHT DEC if ps2x Button PSB_PAD_LEFT Serial print LEFT held this hard Serial println ps2x Analog PSAB_PAD...

Страница 200: ...will be TRUE if any button changes state on to off or off to on if ps2x Button PSB_R3 Serial println R3 pressed if ps2x Button PSB_L3 Serial println L3 pressed if ps2x Button PSB_L2 Serial println L2...

Страница 201: ...ressed Serial println Circle just pressed if ps2x ButtonReleased PSB_PINK will be TRUE if button was JUST released Serial println Square just released if ps2x NewButtonState PSB_BLUE will be TRUE if b...

Страница 202: ...is TRUE Serial print Stick Values Serial print ps2x Analog PSS_LY DEC Left stick Y axis Other options LX RY RX Serial print Serial print ps2x Analog PSS_LX DEC Serial print Serial print ps2x Analog P...

Страница 203: ...1 myservo1 write pos1 servo 1 executes the action the arm will turn right delay 5 if pos1 1 limit the right turning angle pos1 1 turn left if ps2x Analog PSS_RX 50 if push the right joystick to the l...

Страница 204: ...pper arm front if ps2x Analog PSS_RY 50 if push the right joystick upward pos2 pos2 1 myservo2 write pos2 the upper arm will lift delay 5 if pos2 0 limit the lifting angle pos2 0 upper arm back if ps2...

Страница 205: ...g angle pos2 180 void zhuazi close the claw if ps2x Analog PSS_LX 220 if push the left joystick to the right pos4 pos4 1 Serial println pos4 myservo4 write pos4 servo 4 carries out the action and the...

Страница 206: ...log PSS_LX 10 if push the left joystick to the left pos4 pos4 8 Serial println pos4 myservo4 write pos4 servo 4 carries out the action and the claw is gradually opened delay 5 if pos4 108 limit the ma...

Страница 207: ...pos3 1 myservo3 write pos3 the lower arm will stretch out delay 5 if pos3 180 limit the stretched angle pos3 180 if ps2x Analog PSS_LY 10 if push the left joystick downward pos3 pos3 1 myservo3 write...

Страница 208: ...us experiment we have showed how to use Joystick module to memorize several postures Now we replace the joystick module with PS2 Joypad Press the Z1 button to memorize the postures of the arm If you w...

Страница 209: ...ibraries Servo myservo1 create servo object to control a servo Servo myservo2 Servo myservo3 Servo myservo4 int pos1 80 pos2 60 pos3 130 pos4 0 define the variable of 4 servo angle and assign the init...

Страница 210: ...er you conect the controller or call config_gamepad pins again after connecting the controller int error 0 byte vibrate 0 int s1 s2 s3 s4 int jiyi1 20 define four array separately used to save the ang...

Страница 211: ...troller configured successful Serial println Try out all the buttons X will vibrate the controller faster as you press harder Serial println holding L1 or R1 will print out the analog stick values Ser...

Страница 212: ...x Analog 1 HEX ps2x enableRumble enable rumble vibration motors ps2x enablePressures enable reading the pressure values from the buttons void loop myservo1 attach A1 set the control pin of servo 1 to...

Страница 213: ...intln Start is being held if ps2x Button PSB_SELECT Serial println Select is being held if ps2x Button PSB_PAD_UP will be TRUE as long as button is pressed Serial print Up held this hard Serial printl...

Страница 214: ...rial println ps2x Analog PSAB_PAD_DOWN DEC vibrate ps2x Analog PSAB_BLUE this will set the large motor vibrate speed based on how hard you press the blue X button if ps2x NewButtonState will be TRUE i...

Страница 215: ...100 Serial println s2 s3 myservo3 read delay 100 Serial println s3 s4 myservo4 read delay 100 Serial println s4 jiyi1 i s1 save the servo value read in the array sequentially jiyi2 i s2 jiyi3 i s3 ji...

Страница 216: ...r loop to execute all the stored actions if pos1 jiyi1 k if the current servo 1 angle is less than the value stored in array 1 while pos1 jiyi1 k while loop make servo turn to the position of value st...

Страница 217: ...i1 k while loop make servo turn to the position of value stored in the array myservo1 write pos1 servo 1 executes the action delay 5 delay 5ms controlling the rotating speed of servo pos1 Serial print...

Страница 218: ...www keyestudio com Serial println pos1 else while pos2 jiyi2 k myservo2 write pos2 delay 5 pos2 Serial println pos1 the same analysis if pos3 jiyi3 k while pos3 jiyi3 k myservo3 write pos3 delay 5 po...

Страница 219: ...www keyestudio com Serial println pos1 else while pos3 jiyi3 k myservo3 write pos3 delay 5 pos3 Serial println pos1 the same analysis if pos4 jiyi4 k while pos4 jiyi4 k myservo4 write pos4 delay 5 po...

Страница 220: ...keyestudio com Serial println pos1 else while pos4 jiyi4 k myservo4 write pos4 delay 5 pos4 Serial println pos1 if ps2x Button PSB_L2 Serial println L2 pressed if ps2x Button PSB_R2 Serial println R2...

Страница 221: ...TRUE if button was JUST pressed Serial println Circle just pressed if ps2x ButtonReleased PSB_PINK will be TRUE if button was JUST released Serial println Square just released if ps2x NewButtonState...

Страница 222: ...print stick values if either is TRUE Serial print Stick Values Serial print ps2x Analog PSS_LY DEC Left stick Y axis Other options LX RY RX Serial print Serial print ps2x Analog PSS_LX DEC Serial prin...

Страница 223: ...g PSS_RX DEC pos1 pos1 1 pos1 subtracts 1 myservo1 write pos1 servo 1 carries out the action and the arm will turn right delay 5 if pos1 1 limit the right turning angle pos1 1 if ps2x Analog PSS_RX 50...

Страница 224: ...limit the left turning angle pos1 180 upper arm void xiaobi upper arm front if ps2x Analog PSS_RY 50 if push the right joystick upward pos2 pos2 1 myservo2 write pos2 the upper arm will lift up delay...

Страница 225: ...myservo2 write pos2 the upper arm will go down delay 5 if pos2 180 limit the declining angle pos2 180 void zhuazi close the claw if ps2x Analog PSS_LX 220 if push the left joystick to the right pos4...

Страница 226: ...t in 37degrees is closed pos4 0 open the claw if ps2x Analog PSS_LX 10 if push the left joystick to the left pos4 pos4 8 Serial println pos4 myservo4 write pos4 servo 4 carries out the action and the...

Страница 227: ...k upward pos3 pos3 1 myservo3 write pos3 the lower arm will stretch out delay 5 if pos3 180 limit the stretched angle pos3 180 if ps2x Analog PSS_LY 10 if push the left joystick downward pos3 pos3 1 m...

Страница 228: ...e posture Next press the left button of the PS2 joypad to perform postures 5 4 PS2 Controls Posture Memory and Loop Description In the previous experiment we have showed how to use Joystick module to...

Страница 229: ...udio com move them and press the right button again That indicates that actions of the arm are memorized Next you can press the left button to perform actions saved Connection Diagram Test Code13 incl...

Страница 230: ...initial value that is the boot posture angle value PS2X ps2x create PS2 Controller Class right now the library does NOT support hot pluggable controllers meaning you must always either restart your Ar...

Страница 231: ...yservo2 write pos2 myservo3 write pos3 myservo4 write pos4 delay 1500 error ps2x config_gamepad 13 11 10 12 setup GamePad clock command attention data pins check for error if error 0 Serial println Fo...

Страница 232: ...to enable debug visit www billporter info for troubleshooting tips else if error 2 Serial println Controller found but not accepting commands see readme txt to enable debug Visit www billporter info...

Страница 233: ...rate read controller and set large motor to spin at vibrate speed if ps2x Button PSB_START will be TRUE as long as button is pressed Serial println Start is being held if ps2x Button PSB_SELECT Serial...

Страница 234: ...FT DEC if ps2x Button PSB_PAD_DOWN Serial print DOWN held this hard Serial println ps2x Analog PSAB_PAD_DOWN DEC vibrate ps2x Analog PSAB_BLUE this will set the large motor vibrate speed based on how...

Страница 235: ...ln s1 s2 myservo2 read delay 100 Serial println s2 s3 myservo3 read delay 100 Serial println s3 s4 myservo4 read delay 100 Serial println s4 jiyi1 i s1 save the servo value read in the array sequentia...

Страница 236: ...ervo posture pos2 myservo2 read pos3 myservo3 read pos4 myservo4 read while tt 1 repeat the actions for int k 0 k j k for loop to execute all the stored actions if pos1 jiyi1 k if the current servo 1...

Страница 237: ...lse if the current servo 1 angle is greater than the value stored in array 1 while pos1 jiyi1 k while loop make servo turn to the position of value stored in the array myservo1 write pos1 servo 1 exec...

Страница 238: ...udio com while pos2 jiyi2 k myservo2 write pos2 delay 5 pos2 Serial println pos1 else while pos2 jiyi2 k myservo2 write pos2 delay 5 pos2 Serial println pos1 the same analysis as the previous servo if...

Страница 239: ...udio com while pos3 jiyi3 k myservo3 write pos3 delay 5 pos3 Serial println pos1 else while pos3 jiyi3 k myservo3 write pos3 delay 5 pos3 Serial println pos1 the same analysis as the previous servo if...

Страница 240: ...237 www keyestudio com while pos4 jiyi4 k myservo4 write pos4 delay 5 pos4 Serial println pos1 else while pos4 jiyi4 k myservo4 write pos4 delay 5 pos4 Serial println pos1 exit the looping...

Страница 241: ...sures ps2x read_gamepad false vibrate vibrate ps2x Analog PSAB_BLUE if ps2x NewButtonState will be TRUE if any button changes state on to off or off to on if ps2x Button PSB_R3 tt 0 i 0 break if ps2x...

Страница 242: ...button was JUST pressed Serial println Circle just pressed if ps2x ButtonReleased PSB_PINK will be TRUE if button was JUST released Serial println Square just released if ps2x NewButtonState PSB_BLUE...

Страница 243: ...if either is TRUE Serial print Stick Values Serial print ps2x Analog PSS_LY DEC Left stick Y axis Other options LX RY RX Serial print Serial print ps2x Analog PSS_LX DEC Serial print Serial print ps2...

Страница 244: ...servo1 write pos1 servo 1 carries out the action the robot arm turns right delay 5 if pos1 1 limit the right turning angle pos1 1 turn left if ps2x Analog PSS_RX 50 if push the right joystick to the l...

Страница 245: ...nt if ps2x Analog PSS_RY 50 if push the right joystick upward pos2 pos2 1 myservo2 write pos2 the upper arm will lift up delay 5 if pos2 0 limit the lifting angle pos2 0 upper arm back if ps2x Analog...

Страница 246: ...pos2 180 void zhuazi close the claw if ps2x Analog PSS_LX 220 if push the left joystick to the right pos4 pos4 1 Serial println pos4 myservo4 write pos4 servo 4 carries out the action and claw is grad...

Страница 247: ...ick to the left pos4 pos4 8 Serial println pos4 myservo4 write pos4 servo 4 carries out the action and claw is gradually opened delay 5 if pos4 108 limit the maximum angle opened pos4 108 void dabi lo...

Страница 248: ...will stretch out delay 5 if pos3 180 limit the stretched angle pos3 180 if ps2x Analog PSS_LY 10 if push the left joystick downward pos3 pos3 1 myservo3 write pos3 the lower arm will draw back delay 5...

Страница 249: ...bot arm then press the left thumbstick to perform postures saved Hold down the right thumbstick to exit the loop of postures Test Result Stack the shield onto V4 0 and upload the code Powered on and c...

Отзывы: