The Forklift is the most complex construction from the CODEBOX Drive Kit. It is also the most fun. 🙂 In this lesson, we are going to make a program that will allow us to steer the forklift and carry light objects on the pallets.
Preparations
- You will need the Forklift.
- Connect the Forklift with LOFI Blocks.
- Make sure the powerbank in your Forklift is pulled outside as far as it can be. It will act as the counterweight to objects carried on the pallets.
Programming
Steering the Forklift is almost the same as steering the Rover. That is why in this lesson we will focus on using the hoist of the Forklift.
Since lifting cargo is a task that needs to be done carefully and precisely, we can’t allow the vehicle to move too fast. We will use 50% – 70% power on the motors to make the steering easier.
Steering the vehicle
The first part of our program is making the vehicle to move using the arrow keys on your keyboard. You’re probably familiar with a program such as that because we’ve already covered that lesson here: controlling vehicles with the keyboard.
The final program for this part of the lesson should look like this:
Notice two things here:
- The power of the motors is set on different values when moving forwards. The reason for this is that DC motors are rarely perfectly identical, so their performance may differ. That’s why we need to set different values to “synchronize” them. We advise you to experiment with your settings.
- When turning left and right, one motor halts and the other propels the turn. This makes the robot turn slower and makes it easier to control.
Controlling the hoist
The next part of our Forklift steering program is controlling the hoist. We need our hoist to be set to two different positions: down for loading cargo and up for moving with the cargo. We will be switching the positions with Z and X keys (or A and B buttons in our mobile app).
First, we need to find the right servo position for loading cargo and moving with the cargo. In order to do that, put the SET SERVO block in the loop, and try different values to find the ones that you think will work the best.
In our case it’s:
- Servo in 100 – for hoist up position.
- Servo in 20 – for hoist down position.
Notice. We can’t us 0 value for the servo position, because the hoist will block the vehicle. Additionally, the hoist needs to be slightly above the ground to be able to slide the forks inside the pallets.
Since we’ve found the right positions for the hoist, we can go ahead and assign keyboard keys to those positions. Let’s use the WHEN PRESSED… blocks to set the hoist to up position when Z key is pressed, and down position for X key, like this:
Works great, but we can make it more interesting than this 🙂 We can add signaling with LEDs. Let’s try this:
- When Z is pressed, lift the hoist, turn on green LED, turn off red LED.
- When X is pressed, lower the hoist, turn off green LED, turn on red LED.
And with this step completed, our program is ready. Congratulations and have fun with your Forklift!
What next?
The Forklift is perfect for competition. If you have a few Forklifts around, you can hold a competition where the pallets are set in the center of the room, and the goal of the game is to get the most of the pallets to one’s base.
If you work alone, a fun thing to do is precise stacking pallets. Try putting 3 pallets on top of each other. 😉