Technology lessons for educational technology integration in the classroom. Content for teachers and students.

Robotics, Coding Alex Robotics, Coding Alex

While Loop on mBot

In this lesson, you will learn how to use a loop to accelerate and decelerate. Loops are an important part of developing autonomous programs. The purpose of a robot is to perform a series of tasks. Most tasks are specific to a particular objective. Many tasks include repetitive operations. Robots can perform repetitive tasks all day long.

while loops mBot coding

In this lesson, you will learn how to use a loop to accelerate and decelerate. Loops are an important part of developing autonomous programs. The purpose of a robot is to perform a series of tasks. Most tasks are specific to a particular objective. Many tasks include repetitive operations. Robots can perform repetitive tasks all day long.

This lesson will cover a simple task. The robot will gradually accelerate to its top speed; it will then reduce speed to a full stop.

We will be using the remote to start and control the process.

The link to the finished code is available below.

https://planet.mblock.cc/project/502092

We are building the program with the basic building blocks that are particular to this task. The aim is to show you how programmers develop programs. Programmers build and test parts of the program as they go. The program evolves to become the completed product. Testing is important during the development process.

The online version of the mBlock coding environment is at https://ide.mblock.cc

Building the program

Open the mBlock application. Click inside the project name field and set the name to accelerate-decelerate. Click the Save button.

file name save button

Go to the Devices section and click the Add button.

add devices button

Select the mBot library; click the OK button.

mBot library selection

We can set the mBot library to be loaded each time we create a new project. Click the Star icon. The mBot library will load each time a new project is created.

selected to mostly used devices

Delete other Device libraries. This prevents us from accidentally selecting code blocks that don’t work with the mBot.

delete other device library

We want the robot to move forward and accelerate. The process begins when the Up button on the remote is pressed.

Go to the Control functions section and place an **if…then** code block on the canvas.

if…then code block

Go to the Sensing section and get the **IR remote pressed** code. Place it into the **if…then** parameter.

remote code block

Choose the **Up** option from the button selector.

button selection option

We want the robot to slowly accelerate when the Up button is pressed. To perform the acceleration process we need to use a loop. We want the loop to repeat until it reaches the maximum velocity.

We don't know the robot's velocity. We only know the amount of energy applied to the robot motors. The energy is supplied by the batteries. The batteries supply current to the robot's controller and the motors.

The energy we supply to the robot's motors is like the gas pedal on a car. We supply fuel to the engine and the engine, in turn, uses the fuel to propel the car forward. A speedometer in the car lets us know how fast we are going.

The robot does not have a speedometer, so it's like driving a car without a speedometer. We don't know how fast the robot is traveling. We can take some measurements and perform a bit of math to know the robot's acceleration and velocity.

There are three loop options we could use. We are using the repeat **until loop**. We are using this loop because we want the robot to accelerate **until** it receives the maximum amount of energy available.

Go to the Control section. Place a **repeat until** loop within the **if…then** condition.

repeat until loop

Go to the Action section. Place the **move forward at power** code block inside the loop.

move forward code

We need a way to increase the power applied to the motors. The power applied to the motors is based on a percentage of the available battery power. The current value in the move forward code is constant. It doesn't change while the program is running. To update the percentage, we need a variable.

Go to the Variables section; click the **Make a Variable** button.

make a variable

Use **Power** for the variable name. Select the option to use this variable for this sprite only. Click the OK button.

variable block and OK button

Grab the Power variable.

power variable

Place the variable into the Power parameter.

variable in parameter

The variable accepts input from several sources. Attach the **set Power** code to the beginning; before the **if…then** code.

It is recommended to initialize variables before they are used. This block is not in the loop because it sets the initial value of the power before it is changed. The initial value is set to zero.

power variable set to zero

Place the Change Power code inside the loop and above the Move forward code. This code, increases, the value of the power applied to the motors. The value for the power ranges from 0 to 100 percent. The power can be increased by any increment we want. The increment determines the rate of acceleration. Small increments result in slow acceleration. Large increments result in a fast acceleration.

change power code block

Let’s begin with an increment of 10 percent. Place 10 inside the parameter.

change power by value

This will repeat until the robot reaches a maximum of 100 percent. The loop needs a condition. The condition informs the loop when it is time to stop looping.

Go to the Operators section. Look for the **Equal to** operator. This is an evaluation operator. It evaluates if something is equal to something else. This isn't like the equal sign in traditional math. This sign looks to see if two or more values are the same.

equal to operator

Place the evaluation operator inside the repeat parameter.

evaluation operator

Go to the Variables section. Place the Power variable inside the left side of the evaluation.

power variable in operator

Change the value from 50 to 100.

value set to 100

This is a good place to stop and test what we have done. The robot is going to be moving, so we need to make sure it stops at the end of the loop. Go to the Actions section; place the Stop moving code at the end of the if..then code.

stop moving code block

Connect the robot to the computer and turn the robot On. Click the Connect button. Select the port for your robot and complete the connection.

connection button

Click the Upload button.

upload button

Go to the Events section. Attach the When mBot starts up code to the beginning.

mbot start up

Click the Upload button.

upload button

Disconnect the robot and place it on the ground. Please, don’t do this on a table or desk.

Press the Up arrow on the remote.

**Nothing is happening!**

Sorry, I set this up as our first bug in the code. I often make this mistake.

It also provides a teachable moment.

Code that is waiting for input from a user needs to be placed in a Loop. This forces the code to keep checking for input.

Connect the robot back to your computer. Detach the if…then code from the set power code.

disconnect code

Get the Forever loop from the Control section and attach it below the Set Power code.

forever loop

Take the If…Then combined code blocks and place them within the Forever loop.

insert if then look

We can upload this code to the robot and the robot will receive the command from the remote. The robot will power up and move forward. You will see it move away at the fastest speed. It won’t perform a gradual acceleration. This introduces another bug.

The controller processes the instructions very fast. The processor on the controller is not as fast as the one on your typical computer. It is still fast. It processes information at 16 MHz. That is 16 Mega-Hertz or 16 million instructions per second!

The processor increases the speed so fast that it reaches 100 percent almost instantly. We need to slow things down.

Go to the Control section and place a Wait 1-second delay after the Move forward code. With the code, the robot will move forward at a certain Power for One Second. The Power will increase to the next level and the robot will move at that Power level for One Second. It will repeat this process until the power level reaches 100 percent.

wait code block

The robot is set to accelerate until it reaches 100 percent of the available power. It will keep going unless we do something to slow it down or stop it. Give it a try. No bugs this time.

Not on the table or desk!

Let’s slow the robot and bring it back to a stop after accelerating. The next process is to decelerate the robot. The code to do this is almost identical to the code for acceleration.

Move your mouse pointer over the Repeat until code. Right-click on the code; select duplicate.

duplicate option

The duplicate code attaches itself to the mouse pointer. Move the pointer to the end of the **Repeat until** code. Wait for the code blocks to separate; release the code. The code must be right after the first repeat until code.

another repeat until code block

The second code will repeat the loop until the Power level is zero. Place the number 0 into the comparison operator for Power.

zero in operator

We need to decrease the power supplied to the robot through each cycle. Change the positive 10 increments with negative 10, -10.

power value

That is all we need to do. The robot will accelerate up until it reaches 100 percent of the available power. It will then begin to decelerate until no more power is sent to the motors.

Some lights

I like to add some visuals to my robot code. It provides feedback, so I can see at what stage of the code the robot is operating.

Go to the Show section. Get the **LED all** code. Attach it to the first repeat until loop at the beginning.

LED code

Click the color selector and move the color slider; choose green. When the LEDs are green, I know the robot is in the acceleration loop.

color selector

Add an LED code block to the second repeat loop. Place it in the same position. Leave the color set to red. When the LEDs are red, I know the robot is in the deceleration loop.

another LED code

Place one last LED code block outside the second repeat loop. Select the color picker; move the brightness slider to the left. This turns the LEDs off.

brightness slider

Upload the code to the robot. Place the robot on the floor and press the Up arrow on the remote.

The program is in a loop. Press the Up arrow when the robot stops to repeat the process.

Read More
Robotics Alex Robotics Alex

Basic Navigation with mBot and the remote

In this lesson, we are covering the fundamentals for controlling the mBot with the remote. We will cover the button options for driving the robot around. The mBot robot from Makeblock is a good STEM tool. The robot is a motorized vehicle with basic motor controls and sensors. The controller has several sensors, LEDs, and a small speaker.

MBot remote basics navigation

The mBot robot from Makeblock is a good STEM tool. The robot is a motorized vehicle with basic motor controls and sensors. The controller has several sensors, LEDs, and a small speaker. There are plenty of things we can do with this robot. One fun option is to drive the robot around. The kit comes with a remote.

In this lesson, we are covering the fundamentals for controlling the mBot with the remote. We will cover the button options for driving the robot around.

Connect the mBot to your computer with a USB cable. Open the mBlock application or use the online version at https://ide.mblock.cc/#/. Click on the untitled name box.

project title field

Set the name to Drive with remote.

project file name and title

Click the Save button.

save button pressed

Login with your account information.

account login fields

Go to the Devices section; click the Add button.

add button for device library

Select the mBot device library.

mBot library

Return to the Devices section; remove any other device libraries. This avoids conflicts with other libraries that don’t work with the mBot.

remove other device library

Go to the Control functions section; place an if…then…else block onto the canvas. An if…then…else code block checks if something is true or false.

if…then…else code block on canvas

Go to the Sensing functions section; place the IR remote pressed block into the if…then parameter. This is the parameter used to check if it is True or False; if the button is pressed or not.

remote code block

Use the button selector and choose the Up button.

code block up option

Go to the Action functions section; place the move **forward at power** block into the Then space. If the button pressed is the Up button, True, then the robot will move forward at 50% power.

move code block

We need to provide instructions if another button is pressed. This requires another code block to evaluate the press of another button. Go to the Control functions. Place an **if…then…else** block inside the **Else** area of the other **if…then…else** block.

if…then…else code block

Place an **IR remote** block from the Sensing functions inside the if…then parameter.

code block in parameter

Change the button pressed; select the down button.

down option selected

Place a **Move forward at power** into the **If…then** section.

move forward code

Click the Move forward selector and choose the move backward option.

move backward option

Place and **if…then…else** code block into the else portion of the previous code block.

if…then…else code block

Place the IR remote code into the **if…then** parameter. Select the Left button option.

IR remote code

Place the **Move forward** code block into the **if…then** section of the code. Use the Turn left option for the motion.

code and selected options

Place an **if…then…else** code within the else portion of the previous code. Place an **IR remote** code in the if…then parameter and select Right for the button option. Place a **Move forward** code block into the if…then section of the code; choose right for the motion parameter.

applied code block

We are done with all the basic motion options.

The Loop

The robot controller needs to keep checking for a button to be pressed on the remote. We need to place these condition statements inside a loop.

Go to the Control functions section; find the Forever loop code.

Forever loop

Move the Forever loop over the condition code blocks. Move it toward the beginning of the code. We want the code to wrap around all the condition code blocks. Look for a gray shadow of the Forever block to wrap itself around the condition code. Release the block when the shadow appears.

code block shadow

The Forever loop must be wrapped around all the condition code blocks.

forever loop around condition code blocks

We are done with the code. Make sure the robot is connected to the computer and turned On.

Click the Upload button.

upload button

Go to the Events functions. **When mBot starts up** block should be the only one available for selection.

mbot event block

Attach the **When mBot starts up** code to the beginning.

mBot event block attached

Click the Connect button.

connect button

Select the communication port for your robot and connect.

robot connection port on Mac

Click the Upload button.

upload button

Wait for the code to upload to the robot controller. Place the robot on the floor. Press the Up button to move forward. Press the Left or Right buttons. Press the Down button.

Go and play for a while. I'll be here when you are ready for the next part.

The robot moves in the direction the button is pressed until another button is pressed. This is fine but it may lead to some crashes. It also makes it difficult to place on a table when we need to update the code.

Turn the robot Off for now and connect it to your computer.

Go to the Action functions; add the Stop moving code to the Else portion of the last condition code block.

stop code block attached

This code block will stop the robot from traveling endlessly. It will stop if none of the required buttons is pressed.

Hold the robot in one hand or have a partner hold the robot. You can also place the robot upside down if it has a protective case around the controller. Turn the robot On.

Click the Connect button. Select the communication port. Upload the updated code.

Place the robot back on the floor. Press and hold the Up button. Release the button and the robot will stop moving. Press and hold any of the direction buttons. The robot moves only while one of the required buttons is pressed.

This option makes it easier to navigate and control the robot’s movements.

Read More
Robotics, Coding Alex Robotics, Coding Alex

Trigger mBot code with event inputs

In this article, we pick up where we left of last week. You will learn how to use inputs from the mBot remote to control when the robot runs code. You will learn how to use the button on the robot to do the same operation. In the end, we will combine them into one code block.

mBot robotics trigger events with the remote and onboard button

Using the remote

In last week’s article, mBot Robot and Basic Motion, we used a simple code block to move our robot forward. This allowed us to use the robot to learn about motion, velocity, and acceleration. By adjusting the power applied to the motors we increased or decreased the velocity. The robot travels longer or shorter distances when we adjust the duration that power is applied to the motors.

I’m sure you adjusted the code and uploaded it several times. Each time you had to take care that the robot didn’t run off the desk or table. I’m sure this proved inconvenient on more than one occasion.

We are going to place a condition in our code so the robot doesn’t begin to move as soon as we upload our code. A condition is an event that must take place before segments of code are performed.

The robot comes with a remote. It doesn’t come with a battery though. You will need to insert one. I believe it is a CRC-2032 battery. This remote will serve as our event.

Open the mBlock software and create a new project. Title the project Remote Event. Load the mBot code library. Click the Add button in the devices panel.

Devices section

Click on the mBot icon and click the Add button to load the libraries.

available device libraries

Go to the Control category. Find the Forever code block. This is a loop that will repeat the steps we place inside. It will repeat these steps until we turn the robot OFF.

control code blocks section

Place the Forever block on the canvas.

forever code block on coding canvas

Drag the “If…then” code block and place it within the Forever loop.

if…then condition statement in forever loop

Go to the Actions category. Find the move forward code block. Place the block inside the “If…then” condition.

move forward code block inside condition block

We need to set the condition to begin the Move code. Go to the Sensor category.

sensing category code blocks and IR remote code block

Look for the “IR remote A pressed?” code block.

IR remote code block

Place the code block inside the condition parameter. The parameter will highlight when the piece is in the right position.

IR remove code block in condition parameter

The remote code block has a parameter. This parameter waits for one of the buttons on the remote to be pressed. The “A” button is automatically selected. Click the triangle next to the letter to reveal more button options.

button pressed options list

Select the “Up” button. I recommend each student uses a different button. This will prevent the robot from receiving a signal from a stray remote.

Up button selection

The code is complete. Upload the code to the robot. The robot will not move as soon as the program is uploaded. Disconnect the robot and place it on a flat surface. Press the Up button on the remote. The robot will move forward for 3 seconds. Press the Up button again and the robot will move forward again for 3 seconds.

The robot repeats the process because we placed the condition inside a forever loop. The condition does not need to be placed within the Forever loop. Placing the condition in the loop makes it convenient if we want to run the code blocks again and again. Without the Forever loop we would need to turn the robot OFF then On again to use the remote to trigger the event.

completed code with mBot starts up code block at the beginning

Use this code block for any future projects. Place all your code within the condition block.

Using the onboard button

You might not have a remote with the robot or a battery for the remote. There is a button on the robot we will use to trigger the event. The code for the onboard button is almost identical. Click and drag the IR remote code block out of the If…then parameter.

remove IR code block from condition statement parameter

Drag the IR remote code over the Code panel. The panel will change to a light grey color. A trashcan will appear. Release the code block.

trashing IR remote code block

Look for the “When on-board button pressed” code block. It is in the Sensor category.

sensor category and on-board button pressed code

Place the code block in the parameter for the condition block. The code block has a parameter. The parameter is set to the button pressed. This is what we want.

on button pressed code attached to condition

The code is all set. Upload this to the robot. Press the button on the mBot. Using a button is a good option if you don’t want a remote from another robot to trigger the event on your robot.

Combine conditions

The IR remote and button can both be used. We will place both conditions in one code block. To use both conditions we need to use an operator. We are going to use a Boolean operator. There are three Boolean operators. They are AND, OR, and NOT. They are often used to connect and define relationships.

Remove the “When on-board button pressed” code and leave it on the canvas.

remove when on-board button pressed

Go to the Operators category. Find the “or” operator.

OR operator

Place the OR operator in the "If…Then" condition parameter. The OR operator has two parameters. The code for the button will be on one side. The code for the IR remote will be on the other. One condition or the other must be met for the move action to take place.

OR operator in condition block parameter

Place the “when on-board button pressed” code on the right side of the OR operator. It doesn’t make a difference on which side it is placed. The OR operator will work the same.

on-board button pressed code on right side of OR condition

Find the IR remote code in the Sensor category. Place it on the left side of the OR operator. Choose a button to trigger the event.

IR remote code to left of OR

Upload the program to the robot. Try the remote or the button. One of them will start the robot moving.

Read More
Robotics Alex Robotics Alex

The mBot robot and basic motion

The mBot robot is useful when teaching math, science, and coding concepts. Once the robot is assembled we begin with the fundamentals. These fundamentals include coding the robot’s microcontroller to activate the motors so mBot moves.

mBot robotics basic motion math science coding

Basic math, science, and coding concepts

I like using the mBot in the classroom. It is useful when teaching math, science, and coding concepts. Once the robot is assembled we begin with the fundamentals. These fundamentals include coding the robot’s microcontroller to activate the motors so mBot begins to move around. Once the robot is moving we begin to learn about motion, velocity, and acceleration. This leads to lessons on Newton’s Laws of Motion.

Make sure the robot is not on a table where it can easily roll off and come crashing to the floor. I recommend placing the robot on the floor for the first few examples. You can also place the robot on a small paperback book so the wheels are free to spin.

The application to program the mBot is available online or as a download for your computer or device. Go to https://mblock.cc. Programming in the browser version of mBlock 5 requires an account. There is account integration with Google so students can easily create their accounts. This is useful if your school district uses Google account services.

Create a new project by clicking the new project button on the startup page. Provide a title for the project. Click the word Untitled next to the image of a diskette.

title the mBlock project

Name the project “Move forward and back”. Don’t include the quotation marks.

move forward and back title

We need to load the robot into the development environment. Loading the robot loads the code library for the robot. This code library provides some specific code blocks for mBot.

Go to the Devices section under the Stage and click the Add button. The button is next to the Cody Device.

add a device

A Device selector window will open. Click the mBot device and click the OK button.

mBot device library

There are two devices in the Devices section. The mBot device is selected. A blue highlight appears around the selected device.

mBot device selected

The codes panel updates with the categories and code blocks for the mBot. The first code block in the Action category is used to instruct the robot to move forward.

mBot action code blocks

Using code blocks to build scripts is easy and intuitive. Click and drag the first code block onto the canvas area on the right. This code block has two number values. These values are inside small ovals.

move forward code block

The move forward code block is used to send instructions to the micro-controller on the mBot. The micro-controller sends instructions to all the components on the board. It also sends instructions to the components attached to the board.

The micro-controller interprets the instructions in the code block. The instructions in the current code block will send fifty-percent of the available energy to the motors. It will send this amount of energy for one second. That isn’t much time. We will change these values later.

STEM Integration

Let’s take a closer look. The code here relates to some basic concepts in science. The mBot has a battery pack. It uses four double-A batteries. Each battery is 1.5 volts. There are four of these batteries. That is a combined voltage of 6 volts. Volts are potential energy. Potential energy is a concept covered in physical science.

The code block instructs the micro-controller to send fifty-percent of this potential energy to the motors. The energy is released as current. Current is the flow of electrons from one end of a circuit to another. We can determine the current sent to the motors with a math formula. This formula is taken from

Ohm’s law. Ohm’s law is a formula used to calculate current, resistance, or voltage in a circuit. To determine the current sent through a circuit, we divide the voltage by the amount of resistance in a circuit.

We don’t need to know the exact amount of current sent to the motors. It is enough that we use this moment to apply classroom concepts to real-world applications. We must use the proper academic language.

Through the use of this model, we show students potential energy at work. They understand that the current is flowing through the motors to move the robot. They understand that one form of energy is being converted into another form.

There is another concept that we can teach with math and science. That concept is time. Using the code block, we send current to the motors for one second. We will change this value later to something more reasonable. It is important to note that the code does not have instructions for values that relate to miles per hour or even feet per minute. The values have nothing to do with the measurement of distance.

The values relate to energy and time. These two concepts are closely related to concepts taught in astronomy, physical science, and math. In space, distance is commonly measured in time. For example, the distance from the earth to the sun is 92.96 million miles or 146 million kilometers. Light takes 499 seconds to travel from the sun to the Earth. We call this One Astronomical unit. Light travels at 186,287 miles per second or 299,792 kilometers per second.

There are lots of numbers used to describe the distance from the Sun to the Earth. We can easily get confused when using miles or kilometers. How do we know the sun is that far away from the Earth? Did someone travel there to measure? Did we have a very long measuring tape? We used the constant speed of light to help find the distance. For the most part, light always travels at the same velocity. It is the same almost everywhere we measure. Light is constant. This makes the use of light a reliable measuring tool.

Light is measured in the amount of time it takes to travel from one place to another. The Sun is 499 light seconds from the Earth. The distance to the closest star system is 4.22 light-years. That is about 25 trillion miles or 40 trillion kilometers. A trillion is a number followed by 12 zeros. Time might be easier to understand.

We measure distance in time all the TIME! How long does it take to travel from your city or home town to another city? When children are fussing in the back seat they don’t ask, how many more kilometers ’til we get home? They as when are we getting there. They are already measuring distances in time.

Time is a central part of calculating velocity and acceleration. To determine velocity and acceleration we need a change in time and a change in position. The change in position is the distance traveled from one point to another. The calculation of force requires the calculation of acceleration. Acceleration is part of velocity.

We have strayed far away from the code for the robot. That is part of the point. We can extend and integrate a variety of concepts when using robots for STEM. Coding the robot is a means to an end.

Returning to the code

Let’s get back to the code block. This simple code instruction will help students learn and understand some principles of motion. Students will adjust the code parameters to learn and understand velocity and acceleration.

Update the code block so the mBot travels at half the potential energy for 3 seconds.

move code block with 3 seconds

To upload the code we need to go through a few steps. Connect one end of the USB cable to the mBot. Connect the other end to the USB port on your computer. Turn the mBot ON. Make sure to hold the mBot. Sometimes the mBot wheels will begin to spin. My students often lay the mBot on its back. This leaves their hands free to work with the application and the upload process.

The mBot wheels will roll because it begins to process the instructions in any code uploaded to it from a previous session. The code is saved in the mCore memory. The code in this memory is executed each time the robot is turned on. This is common with devices that have Microcontrollers. The code is cleared out by new code uploaded or by updating the Firmware.

Click the Events category. The code blocks in this category are used to start our instructions. These are conditions that need to be met before the mBot will begin executing the instructions. Some of the conditions include the clicking of a green flag and the press of the space key. These conditions are often used with Scratch and the development of interactive stories and games. These conditions don’t work well with our robot.

The condition block we need is the first one. When mBot(more) starts up. This block is grey. This means the block cannot be selected. We cannot add it to the canvas while it is grey. How can we select it then?

We are currently in test mode. Test mode does not actively connect to the mBot. We need to exit Test mode.

mBot start up event not available

Go to the bottom of the application and look for the Connect button. Above the button is an option for live or upload mode. Click the switch to change to upload mode.

upload mode

The mBot condition block is now available. The condition blocks for the Scratch development environment are grey. This means they are not available for our robot.

other blocks not available

Attach the mBot condition code block to the move code on the canvas.

mBot startup block attached

We need to open a communication link to the mBot from the program. This will allow us to upload the code to the robot. Go to the bottom of the application and click the Connect button.

Uploading is when we send content from our computer to another. We download when we get content from another computer.

connect button

A connection configuration box will open. This configuration box is used to select the USB communication port connected to the robot. The port will be different on Windows and Mac computers. The image below shows the connection port on a Mac computer. The connection is being directed to one of the USB ports.

The connection port on Windows is usually Com3. It can also be Com1 or Com2. Com stands for Communication.

USB communication for Mac

Click the port selector. The available communication ports will be listed. The communication port for the mBot on Mac has a special name. This port is /dev/tty.wchusbserial. The number after the name will depend on your Mac. The important part of the information is “wch”. This identifies the port that communicates with the mBot. Select this port.

other connection port options

Click the connect button.

connecting to the port

A new button appears below the Test button. The connect button changes to Disconnect. Above the Disconnect button is a button to upload our code to the mBot. Click the button to begin the upload process. Make sure the robot will not roll off a table before doing this!

upload button

The mBlock software will compile our instructions. This means the program is checking our instructions for mistakes. It is also converting our instructions into instructions the mCore board understands. The compilation process is both a code checker and a translator.

compilation of code message

The instructions are uploaded after the compilation process is complete. A progress bar will show the upload progress. The upload is usually quick. The mBot will run our instructions once the upload is complete.

upload progress indicator

Turn the robot off. Unplug the cable from the mBot. Leave the other end connected to the computer. We will be returning often to update the code. Each time we update the code it must be compiled and uploaded.

Set the robot on the floor and turn the power switch On. The robot will run the code again. It will do this every time we turn the mBot On.

Read More
Robotics Alex Robotics Alex

Sphero's weight, mass, and density

Sphero is a physical object. It has a mass and it has weight. We will use mass to determine buoyancy. Yes, Sphero floats.

Sphero’s weight mass and density

The Science

Sphero is a physical object. It has mass and it has weight. We will use mass to determine buoyancy. Yes, Sphero floats.

Mass is the amount of matter an object has. The mass of an object remains the same or constant.

The weight of an object is the affect of gravity on an object. The weight depends on the gravity. The gravity on Earth is constant for our purposes. Gravity is affected by altitude on Earth. There is a close connection between mass and weight but they are two separate things.

Gravity relies on the mass of the Earth. It also relies on the elevation of the object weighed. Objects on the surface of the earth feel a greater pull by gravity. Objects in orbit around the earth, like a satellite, don’t feel the pull of gravity as much. This is why objects in space are said to be weightless.

An astronaut on earth could weigh about 200 pounds. In space that same astronaut’s weight can’t be measured. This is because there is not gravity to push down on the weight scale.

This is what makes mass different from weight. The astronaut has not changed. His or her matter has remained the same. Everything is made of matter. Some matter is light and some is heavy. The measurement of this amount of matter is called mass. The more matter something has the greater it’s mass.

Sphero’s Weight

There are a variety of ways to weigh Sphero. The easiest is to use a kitchen scale. Sphero comes with a base for charging. We will use this base to prevent it from rolling off the scale. Get yourself a kitchen scale. Turn on the kitchen scale and place the charging base on the scale. The scale will read the weight of the charging base.

Sphero’s weight in ounces

We need to subtract this weight. There are a couple of ways to do this. The most obvious way is to take the base weight and subtract it from the total weight after adding the Sphero. Another way to eliminate the base weight is to use the Tare option on the scale. Most modern kitchen scales have this option. There is usually a button on the scale that reads Tare.

To use the Tare, press the Tare button on the scale. The scale will eliminate the base’s weight and display a zero. Just like the base was not on the scale.

TARE weight

Place Sphero on the base and read the weight on the scale. In Standard measurement, Sphero weighs approximately 6.35 ounces. In the Metric System, Sphero weighs 180 grams.

Sphero’s weight in grams

Sphero’s mass is 180 grams. The scale compensates for Earth’s gravity. Earth has a constant gravitational pull of 9.807 meters per second squared. The scale eliminates this force from our value.

A Balance scale

Let’s use a balance scale to check our value. Balance scales are used to measure mass. We use a balance scale to measure the mass of one object with the mass of another. We place one object on one side of the scale. On the other side we place objects that have a known mass. The objects are usually metal weights.

Sphero on a balance scale

The mass of the weights is marked on each. We place enough of these weights until the scale is balanced. The total mass placed on the scale is used as a measure of the mass on the other side.

Sphero weighs 180 grams on a balance scale

The the value of the weights placed on the other side of the balance total 180 grams. This agrees with the value from the kitchen scale.

This is part of the scientific process. We take measurements and then we need to verify those measurements. If the measurements are different then we need to understand why.

Buoyancy and Density

We know that Sphero floats. It is water tight. Make sure there are not cracks on your Sphero. These lessons cover buoyancy, density, and water displacement.The buoyancy of something depends on its density. Water has a density of 1. Objects that have a density greater than one will sink. Objects that have a density less than one will float. We will calculate the density of Sphero in a moment.

First, we need to know how we arrived at the density of water. Place a beaker on the kitchen scale. Press the Tare button to set the scale to zero. Pour 250 mL of water into the beaker. Read the measurement on the scale. Make sure the measurement units are in grams. The measurement is the same as the amount of milliliters we placed in the beaker.

To determine the density of water we divide the mass by the volume. The volume in milliliters is 250. The mass in grams is 250. The answer is one. The density of water is one.

Sphero’s Density

Sphero is enclosed in a plastic sphere. We will place Sphero into water and use it to learn about buoyancy and density. Buoyancy is the capacity for something to float. The density of an object has much to do with its ability to float.

We need a container with water. The container needs to have a way for us to measure the amount of water. A beaker is a good container to use if you have one large enough. I find that a two-cup kitchen measuring cup works well if a beaker isn't available. These measuring cups are available at any discount store for a few dollars. They have a nice handle to hold onto.

a regular kitchen measuring cup

Fill the container to the one-cup measurement. Add some food coloring to help you see the water level if necessary.

one cup of water with food coloring

Insert Sphero into the measuring cup. Sphero displaces the water in the measuring cup. Sphero forces the water up and around the measuring cup. The water level rises to one-and-three-quarter cups. Sphero displaces three-quarters of a cup of water.

Sphero displaces water in the measuring cup

Sphero doesn't completely float and it doesn't completely sink either. This is due to Sphero’s density.

To find the density of an object we need to divide the mass of the object by the volume. This is where all the math we did earlier comes together.

Sphero has a mass of 180 grams. It has a volume of 180 cubic centimeters. Sphero’s density is One! This is the same density as that of water. This explains why most of Sphero is submerged in water. Much like an iceberg.

All the science we just did would not be possible without the math we used in the previous lessons. This is that math science connection we are always wanting to make with students.

Read More
Robotics Alex Robotics Alex

Sphero's volume and surface area

Sphero is a sphere with volume and surface area. To calculate this information we need one piece of information. We need to know the radius.

teach math and science with Sphero

Basic math to understand Sphero’s geometry

Sphero is a sphere with volume and surface area. To calculate these values, we need one piece of information. We need to know the radius.

The radius is the distance from the center of the sphere to any point on the surface. We know that a line drawn from one point on the surface through the center and to another point is the diameter. The radius is half the length of a diameter. This information is similar to that of a circle.

There isn't a way for us to measure the radius of our sphere. We would need to disassemble the robot. We can, however, measure around the sphere. There are two values that we can measure. Both of these values will help determine the information we need.

Let’s begin with the easiest. For this exercise we will need a length of string. The string should be at least twelve inches long. The string shouldn't be too thick.

Find the seam along Sphero’s surface. Place one end of the string on a point on the seam. Wrap the string around the seam until it meats up with the string’s starting point. Use a marker or pen. Mark where the string meats the starting point. This measurement isn’t very accurate but we will round our measurement later.

Use a ruler. Place the starting end of our string at the beginning of the ruler’s measurement. Lay the string along the ruler. Find where the point we marked the string lays on the ruler. This is the circumference.The circumference from the measurements of my Sphero resulted in approximately nine and a quarter inches, 9.25in. The equivalent measurement in centimeters is 23 cm. Most rulers have both units of measure.

To determine the radius we need to use the formula for the circumference of a circle. The formula multiplies the diameter by Pi. To solve for radius we need to reformat our formula. This step takes us into the use of algebra.

We want the diameter to be on one side of our equation. Let’s begin by writing down our values into the equation. Take the value of the measurement and write it down. Place an equal sign to the right and then the value of pi, 3.14. Place the multiplication symbol to the right of pi and D for diameter.

solving for the diameter

We need to move the value of pi to the left side of the equal sign. To do this we need to divide by pi. Place a divisor and the value of pi under the circumference. Place a divisor and the value of pi under pi.

When we divide a number by the same number the answer is always one. Pi divided by Pi is one. One times the diameter is the diameter. We don’t need to write the number one.

solving for the diameter

Dividing the circumference by pi gives us the diameter. The diameter in inches is approximately 2.945 inches. The diameter in centimeters is approximately 7.324 cm. The value we get here is an approximation. The diameter is twice the radius. To get the radius we divide the diameter by two. The radius in inches is 1.473 in. The radius in centimeters is 3.662 cm.

Rounding the values for radius would seam to be reasonable but we will stay with this to review operations with decimal values. With the radius of our sphere we have the information needed to solve for surface area and volume.

The surface area of a sphere is calculated by squaring the radius. The product is multiplied by pi. This product is then multiplied by four. We’ll use my measurement in inches first. The radius from my diameter of 2.945, is 1.473. This gives us an approximate surface area of 27.247. We must state the units of measure in the answer. The complete answer is 27.247 square inches.

Sphero’s surface area

The volume is calculated by cubing the radius. This value is multiplied by pi. That value is then multiplied by 4 and divided by 3. The volume is approximately 13.387 cubic inches.

Sphero’s volume

Now we will calculate the surface area and volume using our measurement in centimeters. The radius from our diameter, 7.324 is approximately 3.662. The volume is approximately 205.704 cubic centimeters. The surface area is approximately 168.518 square centimeters.

Recalculate with rounding

The answers from our measurement of Sphero’s circumference are approximations. The string and ruler are not the most accurate tools. I used a Vernier caliper to measure Sphero’s diameter. A Vernier caliper is a ruler with a measurement scale. It is used to take precise measurements. With the caliper I measured Sphero’s diameter at 7 centimeters. Use this updated measurement to recalculate Sphero’s volume and surface area.

using a caliper to determine the diameter

Here are my answers so you can compare. Sphero’s volume is 179.594 cubic centimeters. Round this to 180 cubic centimeters. The surface area is 153.938 square centimeters. Round the value to 154 square centimeters. I will use these values from this point forward.

The information we gathered in these math activities will be used in our science activities. Remember the values for volume because they will come up again later.

Blog banner image inspired by Freepik

Read More