Case 03: A Small Forklift
Purpose
Make a small forklift with NezhaA Inventor's Kit.
Purchse
Materials Required
Assembly Steps
Hardware Connections
Connect two motors to M1 and M2, the two buttons to J1 port on Nezha-A master box.
Programming
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
Sample Projects:
// 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, 50); // Set the speed of the motor connecting to M1 at 50%
delay((2) * 1000); //Pause 2000ms
nezhaA.brakeMotor(M1); //Stop the motor connecting to M1
nezhaA.setMotorSpeed(M2, 100); //Set the speed of the motor connecting to M2 at 100%
delay((1) * 1000);
nezhaA.brakeMotor(M2); //设Stop the motor connecting to M2
}
if (buttonJ1.isPressed(D)) { //While button D is pressed
nezhaA.setMotorSpeed(M1, -50);
delay((2) * 1000);
nezhaA.brakeMotor(M1);
nezhaA.setMotorSpeed(M2, -100);
delay((1) * 1000);
nezhaA.brakeMotor(M2);
}
}
Result
After powering on, press button C and the car drives forward for 2 seconds and the raise its folklift; press button D and the car reverses for 2 seconds, then it puts the folklift down.