14. Case 12: A Handheld Mechanical Claw#

14.1. Purpose#


Make a handheld mechanical claw with NezhaA Inventor’s Kit.

../../_images/neza-a-case-12-01.png

14.2. Purchse#


NezhaA Inventor’s Kit

14.3. Materials Required#


../../_images/neza-a-case-12-02.png

14.4. Assembly Steps#


../../_images/neza-a-step-12-01.png ../../_images/neza-a-step-12-02.png ../../_images/neza-a-step-12-03.png ../../_images/neza-a-step-12-04.png ../../_images/neza-a-step-12-05.png ../../_images/neza-a-step-12-06.png ../../_images/neza-a-step-12-07.png ../../_images/neza-a-step-12-08.png ../../_images/neza-a-step-12-09.png ../../_images/neza-a-step-12-10.png ../../_images/neza-a-step-12-11.png ../../_images/neza-a-step-12-12.png ../../_images/neza-a-step-12-13.png ../../_images/neza-a-step-12-14.png ../../_images/neza-a-step-12-15.png ../../_images/neza-a-step-12-16.png ../../_images/neza-a-step-12-17.png ../../_images/neza-a-step-12-18.png ../../_images/neza-a-step-12-19.png ../../_images/neza-a-step-12-20.png ../../_images/neza-a-step-12-21.png ../../_images/neza-a-step-12-22.png ../../_images/neza-a-step-12-23.png ../../_images/neza-a-step-12-24.png ../../_images/neza-a-step-12-25.png ../../_images/neza-a-step-12-26.png ../../_images/neza-a-step-12-27.png ../../_images/neza-a-step-12-28.png ../../_images/neza-a-step-12-29.png ../../_images/neza-a-step-12-30.png

14.5. Hardware Connections#


Connect the motor to M1 port and thetwo buttons to J1 port on Nezha-A master box. ../../_images/neza-a-case-07-03.png

14.6. Programming#


14.6.1. Prepare the programming#

Steps for preparation please refer to: Arduino 3 in 1 Breakout Board

Import the libraries and the subsidiary libraries of Nezha-A master box and then import the libraries of the two buttons: PlanetXButton-main.zip

14.6.2. Sample Code:#

// Language ArduinoC
#include <RJPins.h>
#include <NezhaA.h>
#include <PlanetXButton.h>

PlanetXButton buttonJ1(J1);    //Create an instance of PlanetXButton category
NezhaA nezhaA;    // Create an instance of NezhaA category
int flag;    //Create a variable flag to document the status of the claw

void setup() {
  nezhaA.begin();    //Initiliaze the buzzer, motor, servo and light
}

void loop() {
  if ((buttonJ1.isPressed(C)) && (flag == 0)) {    //While button C is pressed and the flag is 0,
    nezhaA.setMotorSpeed(M1, 100);   //Set the speed of the motor connecting to M1 at 100%
    delay((1) * 1000);    //Pause 2000ms
    nezhaA.brakeMotor(M1);    //Stop the motor connecting to M1
    flag = 1;    //Set flag=1, label it as the loose of the claw
  }
  if ((buttonJ1.isPressed(D)) && (flag == 1)) {    //While button D is pressed
    nezhaA.setMotorSpeed(M1, -100);   //Set the speed of the motor connecting to M1 at -100%
    delay((1) * 1000);    //Pause 2000ms
    nezhaA.brakeMotor(M1);    //Stop the motor connecting to M1
    flag = 0;    //Set flag=0, label it as the grasp of the claw
  }
}

14.6.3. Result#

Put the claw in a proper position that may grasp the goods, after powering on, press button C and the claw looses the goods; press button D and the claw grasps the goods.