[175] | 1 | /*
|
---|
| 2 | takethesponge.ino
|
---|
| 3 |
|
---|
| 4 | This example commands to the Braccio to take a sponge from the table and it shows to the user
|
---|
| 5 |
|
---|
| 6 | Created on 18 Nov 2015
|
---|
| 7 | by Andrea Martino
|
---|
| 8 |
|
---|
| 9 | This example is in the public domain.
|
---|
| 10 | */
|
---|
| 11 |
|
---|
| 12 | #include <Braccio.h>
|
---|
| 13 | #include <Servo.h>
|
---|
| 14 |
|
---|
| 15 |
|
---|
| 16 | Servo base;
|
---|
| 17 | Servo shoulder;
|
---|
| 18 | Servo elbow;
|
---|
| 19 | Servo wrist_rot;
|
---|
| 20 | Servo wrist_ver;
|
---|
| 21 | Servo gripper;
|
---|
| 22 |
|
---|
| 23 |
|
---|
| 24 | void setup() {
|
---|
| 25 | //Initialization functions and set up the initial position for Braccio
|
---|
| 26 | //All the servo motors will be positioned in the "safety" position:
|
---|
| 27 | //Base (M1):90 degrees
|
---|
| 28 | //Shoulder (M2): 45 degrees
|
---|
| 29 | //Elbow (M3): 180 degrees
|
---|
| 30 | //Wrist vertical (M4): 180 degrees
|
---|
| 31 | //Wrist rotation (M5): 90 degrees
|
---|
| 32 | //gripper (M6): 10 degrees
|
---|
| 33 | Braccio.begin();
|
---|
| 34 | }
|
---|
| 35 |
|
---|
| 36 | void loop() {
|
---|
| 37 | /*
|
---|
| 38 | Step Delay: a milliseconds delay between the movement of each servo. Allowed values from 10 to 30 msec.
|
---|
| 39 | M1=base degrees. Allowed values from 0 to 180 degrees
|
---|
| 40 | M2=shoulder degrees. Allowed values from 15 to 165 degrees
|
---|
| 41 | M3=elbow degrees. Allowed values from 0 to 180 degrees
|
---|
| 42 | M4=wrist vertical degrees. Allowed values from 0 to 180 degrees
|
---|
| 43 | M5=wrist rotation degrees. Allowed values from 0 to 180 degrees
|
---|
| 44 | M6=gripper degrees. Allowed values from 10 to 73 degrees. 10: the toungue is open, 73: the gripper is closed.
|
---|
| 45 | */
|
---|
| 46 |
|
---|
| 47 | //Starting position
|
---|
| 48 | //(step delay M1 , M2 , M3 , M4 , M5 , M6);
|
---|
| 49 | Braccio.ServoMovement(20, 0, 45, 180, 180, 90, 10);
|
---|
| 50 |
|
---|
| 51 | //Wait 1 second
|
---|
| 52 | delay(1000);
|
---|
| 53 |
|
---|
| 54 | //The braccio moves to the sponge. Only the M2 servo will moves
|
---|
| 55 | Braccio.ServoMovement(20, 0, 90, 180, 180, 90, 10);
|
---|
| 56 |
|
---|
| 57 | //Close the gripper to take the sponge. Only the M6 servo will moves
|
---|
| 58 | Braccio.ServoMovement(10, 0, 90, 180, 180, 90, 60 );
|
---|
| 59 |
|
---|
| 60 | //Brings the sponge upwards.
|
---|
| 61 | Braccio.ServoMovement(20, 0, 45, 180, 45, 0, 60);
|
---|
| 62 |
|
---|
| 63 | //Show the sponge. Only the M1 servo will moves
|
---|
| 64 | Braccio.ServoMovement(20, 180, 45, 180, 45, 0, 60);
|
---|
| 65 |
|
---|
| 66 | //Return to the start position.
|
---|
| 67 | Braccio.ServoMovement(20, 0, 90, 180, 180, 90, 60);
|
---|
| 68 |
|
---|
| 69 | //Open the gripper
|
---|
| 70 | Braccio.ServoMovement(20, 0, 90, 180, 180, 90, 10 );
|
---|
| 71 |
|
---|
| 72 |
|
---|
| 73 | }
|
---|