9. Case 07: A Bricks Catapult#

9.1. Purpose#


Make a bricks catapult with NezhaA Inventor’s Kit. ../../_images/neza-a-case-07-01.png

9.2. Purchse#


NezhaA Inventor’s Kit

9.3. Materials Required#


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

9.4. Assembly Steps#


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

9.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

9.6. Programming#


9.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 Download and import the self-defined library connections for Nezha-A master box: RJPins-main.zip

9.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

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

void loop() {
  if (buttonJ1.isPressed(C)) {    //While button C is pressed
    nezhaA.setMotorSpeed(M1, 30);   //Set the speed of the motor connecting to M1 at 50%
    delay((0.5) * 1000);    //Pause 500ms
    nezhaA.brakeMotor(M1);    //Stop the motor connecting to M1
  }
  if (buttonJ1.isPressed(D)) {    //While button D is pressed
    nezhaA.setMotorSpeed(M1, -100);
    delay((0.5) * 1000);
    nezhaA.brakeMotor(M1);
  }
}

9.6.3. Result#

After powering on, press button C to lift the pole, then press button D and the bricks would be flapped out by the pole.