Anything that reduces human effort is called a machine. A simple machine is a mechanical device for applying force. Any complex machine is a combination of two or more simple machines. We will learn how to apply a few of these simple machines in our upcoming projects. In science, there are a total of six simple machines, as follows:
Wheels and axles help move heavy loads from one place to another by reducing the friction between the load and the surface, owing to its round shape. The wheel is considered one of the greatest discoveries of mankind. You can find numerous examples in and around your vicinity where wheels are used extensively to make things move easily, for example, your holiday suitcase! Have you ever tried picking up your suitcase when it is completely full? It is extremely heavy and almost impossible to lift, right? And what does your suitcase have? It has four small wheels at the bottom that makes moving such a heavily loaded suitcase extremely easy and fun. You can find many such applications of wheels and axles in your day-to-day life. Can you think of at least three places where you have seen this application of wheels and axles?
Great! In this chapter, you will make use of wheels and axles to help the robot move freely on the floor. You will also learn about two different types of turns that a robot can perform and execute those turns in the respective activities. Exciting, isn't it?
In this chapter, we will cover the following topics:
In this chapter, you will need the following:
In this section we will build the robot as shown in the following figure:
Follow the given steps to build the robot:
The robot that you have built here uses the two internal motors of your BOOST Hub to power two wheels individually. Your turning becomes possible and easy when your drive wheels are powered individually. Remember one thing – the speed difference between your two drive wheels makes turning possible.
First, let's learn how to make our robot move straight by powering both motors at the same time. We will be using the same programming blocks that we used in Chapter 2, Building Your First BOOST Robot – Tabletop Fan, and Chapter 3, Moving Forward/Backward Without Wheels, but we will be selecting the AB option from the drop-down menu, as shown in the following screenshot. Here, I have written a program to make the robot go forward for two rotations at 100% speed:
Now that you know how to power both motors at the same time, let's write the main code:
Now, let's perform a few activities.
Can you program your robot to do the following?
Great! Now, let's learn how to code our robot to follow an L shape. For this, we need to understand how to turn the robot. There are two different types of turns:
Before you program your robot to turn, you need to learn about one new block; that is, set motor direction:
This block is used to set the direction of the motors. It can be this way (clockwise), that way (anti-clockwise), or Reverse. We will be smart when we use these blocks in our coding from now on; that is, where turns are involved. Let's write some code that makes the robot move in an L shape. Let's assume that the robot will move forward for two rotations, turn, and then move forward for one rotation to draw an L shape. Your code should look as follows:
Which direction did your robot turn? Left, or right? __________ (Space has been left for you to answer.)
Do you know that you can change the motor that you reversed before making this turn to change the turn's direction? Just try it and see how this works. Basically, if you want to turn right, your right wheel should move backward while your left wheel should move forward, and vice versa for the left turn. Also, you need to change the number of rotations that your motors move for while turning to achieve the exact amount of turn that you want. You can set your values in numbers with decimals. Two rotations are fine, but you can also set 2.1, 2.2, or even 2.3 rotations so that you make precise turns every time.
So, which direction did your robot turn? Left, or right? _________ (Space has been left for you to answer.) As the name suggests, the robot swings on one wheel to make the appropriate turns.
Did you notice the stark difference between the point and swing turns here? You will apply these turns based on your needs in the upcoming activities.
Program your robot to move in a square, as shown in the following diagram:
Let's write an algorithm for this code:
Which turn will you be using here – point or swing? Since you need sharp turns at the edges of the square, you must use point turns for this activity. Follow the algorithm and write some code to make your rover move in a square shape. Did you observe something irritating in this code? You are writing the same line of code four times to form a square, hence making this code iterative. Your robot must follow the same action four times – move forward and turn right. How can we reduce these iterations and write fewer lines in the code for the same task? For such repetitive actions, we can use loops. In loop-based programming, you can write basic code that then needs to be followed n times. In the case of this square, you need to repeat an action four times. In such cases where the number of repetitions is specific, you can use a block called repeat from the Control pallet area of Scratch. Let's see how this works! Write the following code on your device:
Just adjust the following parameters before running this code to form a proper square:
Similarly, when you want to repeat some actions forever, you must use the forever block from the Control pallet area:
Try using this forever loop instead of the repeat-based loop in the same code. See what happens. Your robot will constantly move in a square shape until it is stopped by the device. Now that you are good at taking turns and using loop blocks, you may wish to write some code that makes your robot move in a rectangle shape twice:
It looks like you have got the hang of coding your robot to make it move in shapes with accurate turns. Try to code your robot to move in shapes such as triangles, hexagons, and diamonds with the dimensions of your choice.
Once you've done this, you can create your own path with a few left and right turns in it – some sharp, some wide – and try to run your robot through that path. This will enhance your coding skills with your BOOST kit.
Challenge #1
One more way to make turns is by simply running both motors at different speeds. By doing so, your robot will steer just like your car, instead of turning sharp at that very point. This technique can be useful when you want to make smooth, long turns of form shapes such as an arc or a circle. Either draw a big circle or find a big enough circular object in your home and try to code your rover to move around it using this technique.
Challenge #2
Can you build a seesaw using the external motor and LEGO parts in your BOOST kit? A seesaw is a common example of a simple machine lever.
In this chapter, you learned how to use wheels and axles. You applied these to your robot and built your own rover with wheels using the BOOST kit. You also learned about new programming blocks such as set motor direction, repeat loop, and forever loop. We also looked at two different types of turns that are commonly used when coding robots to make them turn; that is, point and swing turns.
In the next chapter, you will be introduced to the fascinating world of gears and how to apply them to build a geared robot. You will perform a few activities to understand concepts such as gear up and gear down. This is going to be a lot of fun!
As we mentioned at the beginning of this chapter, there are six simple machines you can use. We covered wheels and axles in this chapter. You should learn about the other five simple machines as well by going to the following page:
https://www.britannica.com/technology/simple-machine
If you know how to practically apply these simple machines, you will be able to build your own mechanisms in the future.
3.145.191.22