buttonGrabAndDrop
buttonGrabAndDrop
Introduce the conditional "if" statement to grab and drop on command using the Great Big Button(any button will do). This example takes a block from the user and drops it in a bowl. Experiment by changing the robotMove values and the robotGrab values to see how it affects the robots actions. What values do you need for heavy and light items?
Commands Used
if(conditional);
robotMove(x,y);
robotGrab(x);
delay(x);
Setup:
Connect your Great Big Button (or pretty much any other momentary button) to ground and pin 7 as shown. Any pin will do except pins 8 and 9, which are used to communicate with mimicArm. Arduino is shown, but you can use the pins on your mimicArm controller that's attached to your Arduino.
Download buttonGrabAndDrop.ino for Arduino
Cut and paste code:
#include <robot.h> //Tell your arduino to go get the custom mimicArm code
/*This example requires the Great Big Button, or some other button.
Use the pins listed with any button you choose, including our
Great Big Button. Connect button to pin 8 and ground.
*/
int button = 7; //assign variable button to pin 7
void setup() {
// put your setup code here, to run once:
robotActivate(); //Tell the robot that Arduino will be sending it commands
pinMode(button, INPUT_PULLUP); //Set pin 8 to detect a ground.
//NOTE using INPUT_PULLUP will show HIGH when the button is not pressed
//and LOW when it is pressed
}
void loop() {
// put your main code here, to run repeatedly:
robotMode(arduino); //Put the robot in Arduino command mode
robotMove(1, 50); //move base to one side
robotMove(2, 127); //Put the robots 'shoulder' in a natural position
robotMove(3, 127); //Put robot 'elbow' at in a natural position
if (digitalRead(button) == LOW) {
//Now reach out and grab
robotMove(2, 110); //reach forward slightly
robotGrab(100); //grab fairly tightly (127 is max)
delay(2000); //wait 2 seconds to grab
//now move to bucket
robotMove(3, 127); //Put the robots 'shoulder' in a natural position
delay(500); //wait .5 second for everything to move
robotMove(1, 200); //move robot to oposite side
delay(500); //wait .5 second for everything to move
//move to drop position
robotMove(3, 110);
robotMove(2, 100);
delay(500); //wait .5 seconds for everything to move
//drop block
robotGrab(-60); //light opening force on gripper
delay(3000); //wait 30 seconds before repeating
robotGrab(0); //turn off gripper to save motor
}
}