© The Author(s), under exclusive license to APress Media, LLC, part of Springer Nature 2023
G. KochLearn Engineering with LEGOhttps://doi.org/10.1007/978-1-4842-9280-8_1

1. The Hub

Grady Koch1  
(1)
Yorktown, VA, USA
 
The Hub, pictured in Figure 1-1, is a small computer that powers and controls inventions. This book will show how to combine it with sensors and motors to explore many engineering concepts. This chapter introduces the Hub, including how to power it up, charge it, and navigate the controls on its front panel.

A photograph of a hub and a Lego robot placed on a surface.

Figure 1-1

The Hub is a small computer for controlling sensors and motors

While the Hub is meant to be programmed, as will be done throughout this book, it can also control sensor- and motor-based projects by using the front panel of the Hub alone, without any programming needed. This chapter includes two such projects that spin a motor at various speeds.

Assembling and Charging the Hub

The Hub comes in the Robot Inventor (and SPIKE Prime) set in two pieces: the hub and a battery, as pictured in Figure 1-2. The battery snaps into the Hub, with little need to ever remove the battery, except perhaps for swapping out batteries if a spare is urgently needed. The battery is rechargeable and likely needs a fresh charging when first used. Charging is done by the USB cable that comes in the set, with the small connector (called a USB Mini) plugging into the Hub and the large connector (called a USB A) plugging into a computer or USB charger. These USB connections are shown in Figure 1-3. If plugged into a computer for charging, the Hub powers on with a musical chirp and the front panel lights up, and the host computer sounds a notice that it has found new hardware—this can be ignored for now. The Hub can take a few hours for a full charge. There’s a way to check for the level of battery charge, which will be described in Chapter 2. While charging, the features of the Hub can be explored as described as follows.

A photograph of a hub with a disassembled battery along with a Lego character is kept on the surface.

Figure 1-2

The Hub is powered by a removable battery

A photograph of a hub connected to a laptop by a U S B cable for charging the battery.

Figure 1-3

The Hub battery is charged by a USB connection

Controls and Displays

The Hub has several buttons, displays, and a speaker built into it that serve to turn on the Hub and control various features. These control features on the Hub can be for either input or output. Input functions are the buttons on the front panel, while output functions are displays and a speaker.

There are four buttons on the front panel of the Hub used to control functions, pictured in Figure 1-4. The center button is the power control, which, when pressed, turns on the Hub. Another press and hold of at least three seconds turns off the Hub. The center button also executes a program that has been loaded into memory, as will be described in Chapter 2. Next to the center button are the left and right buttons, used to scroll through programs that are stored in the Hub’s memory. With no programs loaded into the Hub, these buttons don’t show any effect yet. But the left and right buttons also serve to increment motor settings, as will be used later in this chapter. Another button is the Bluetooth button, which is pressed to set up a Bluetooth link. Bluetooth is a type of radio link between computers.

A photograph of a hub indicating the position of the Bluetooth button, left button, center button, and right button.

Figure 1-4

The four input buttons on the Hub

Two displays are part of the Hub, pictured in Figure 1-5. One display is a 5 × 5 matrix of yellow LEDs, which are used in Chapter 2 to make shapes, numbers, or letters. But this matrix display is also involved in indicating the status of the Hub. For example, after powering up the Hub, a play symbol (a triangle like on an old-fashioned tape recorder) lights up on the matrix display to indicate that things are working OK. The brightness of the 5 × 5 LED matrix can be changed, but its color can only be yellow.

A photograph exhibits the illuminated 5, cross, 5 L E D matrix, and an illuminated center button light on the hub.

Figure 1-5

Two outputs on the front panel of the Hub are a 5 × 5 LED matrix of yellow lights and a ring around the center button

The other display on the Hub is a colored ring around the center button. When the Hub is first powered, this ring is a white color. In Chapter 2, options will be presented to change the color of the center button light.

As buttons are pressed, various beeping and musical sounds are emitted from a speaker on the side of the Hub, shown in Figure 1-6. Every press of a button gives a sound through the speaker to provide feedback that a button has been pressed. The different button functions have different sounds. For example, when the Hub is turned on by pressing the center button, there is a series of accelerating clicks followed by a musical chirp.

A photograph of a Lego character indicating the speaker provided on the side of the hub to play music and beeps.

Figure 1-6

Sound output is from a speaker on the side of the Hub

As shown in Figure 1-7, all six sides of the Hub have holes for inserting LEGO pins. There are several kinds of pins, which are discussed in detail in Chapter 3. Larger LEGO building elements can be attached to these pins, as will be seen in the upcoming projects of this book.

A photograph indicates several holes present on all sides of the hub. A few holes contain the hub pins. There is a toy LEGO character at the bottom.

Figure 1-7

Pins can be inserted into opening on all the sides of the Hub

Exercise: The Motor Spinner

The Robot Inventor and SPIKE Prime sets come with a variety of motors and sensors. These motors and sensors can be quickly identified by their attached cables, which plug into one of the six ports on the Hub. These motors and sensors can be programmed to do all sorts of sophisticated functions, but the Hub also allows control of a motor or sensor by simply plugging it in, without any programming. This feature can be used to activate a motor or change the speed of its rotation. The Motor Spinner in Figure 1-8 demonstrates this plug-and-play feature.

A photograph exhibits the plug-and-play feature of the hub. A motor is connected to a port of the Hub.

Figure 1-8

The Motor Spinner uses the Hub to control a motor

Instructions to build the Motor Spinner are given as follows. All of the parts for this project, and all the projects in this book, are part of the Robot Inventor set.

An illustration denotes four pins connected at the side of the Hub. It indicates the number of hubs as 1 and the number of ports as 4, at the bottom.

An illustration demonstrates the connection of a motor at the side of the Hub. The motor cable is connected to the port E of the Hub.

An illustration exhibits the connection of two pins on the motor spinner. The motor is connected to port E of the Hub.

An illustration exhibits the connection of the motor spinner. The motor is connected to port E of the Hub.

Activating the Motor

To control the Motor Spinner, the first step is to power up the Hub by pressing the center button. The Hub should chirp, and the matrix should display the play symbol. After another press of the center button, a row of lights next to port E should appear with the LED light closest to the port coming on, along with a square of light moving from right to left. This lit-up row indicates that the Hub has recognized the motor. Since port E is used for motor connection, this row of lights is lit up. If, instead, a different port was used, its associated row would light up. Port E is used in this exercise for convenient routing of the cable and in preparation for the following project. A press of the left button once should activate the motor to spin slowly in a clockwise direction. Pressing the right button once should stop the motor. Another press of the right button will make the motor spin slowly counterclockwise. Motor rotation can be sped up by pressing the right button up to ten times. The left button will slow the motor down. With repeated pressing of the left button, the motor will stop, then begin to speed up in a clockwise rotation. When done using the motor, pressing the center button will go back to the home menu, represented by the play symbol on the LED matrix display.

Project: The Distance Spinner

Sensors can also be read by the Hub without programming, much like a motor can be controlled by just plugging it into the Hub. The Distance Spinner project in Figure 1-9 shows how to include a sensor in a project and uses all the techniques of this chapter. The Distance Spinner spins a motor at a speed that depends on how close the Hub is to an object. The closer the object, the faster the motor will spin. Building instructions are given following Figure 1-9. The Distance Spinner is an extension of the Motor Spinner, so the following instructions start after completion of the Motor Spinner in Figure 1-8.

A photograph exhibits the model for the Distance Spinner attached to the hub. A toy LEGO character is at the bottom.

Figure 1-9

The Distance Spinner will spin faster when objects are closer to the sensor

An illustration exhibits the connection of two pins to the Hub. A motor is already connected to the Hub.

An illustration exhibits the connection of a 7-hole long straight lift arm to the Hub. A motor is already connected to the Hub.

An illustration exhibits the connection of 2 pins on the 7-hole long extension on the side of the Hub. A motor is already connected to the Hub.

An illustration exhibits the connection of the Distance Spinner to the Hub. The cable of the distance spinner is connected to the port F of the Hub.

Using the Distance Spinner

After powering up the Hub with a press of the center button, a second press of the center button will activate the Distance Spinner. The lowest row of the LED matrix display should light up on the front panel, indicating that the Hub has recognized the connection of both the Distance Sensor and motor. If an object, such as a wall, is within about 2 m distance away, the motor will spin. A good test is to stand about 2 m away from a wall with the Distance Spinner facing the wall. In moving closer to the wall, the motor spins faster. When done working with the Distance Sensor, a press of the center button will return the user back to the home play symbol on the Hub’s LED matrix.

Summary

This chapter introduced the Hub, the computer heart of the Robot Inventor or SPIKE Prime set. The Hub uses a rechargeable battery for power, which can be charged by a USB connection. There are a number of displays on the Hub, including LEDs, as well as a speaker for audio output. Input to the Hub includes several buttons to navigate the front panel control and displays. The center button on the Hub turns the Hub on and off. The Hub offers simple functionality for the motors and sensors without a need to program the Hub, and two quick building projects showed the use of the Hub with the Distance Sensor and a motor. Of course, the Hub is meant to be quite versatile with programming, which Chapter 2 delves into.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
18.189.2.122