Sometimes we have a numeric variable that is an input parameter for many commands but must sometimes be a negative value. There are several ways to use this variable without changing it.

To access the full video please subscribe to FLLCasts.com
- #1552
- 27 Feb 2020
Multiplying by negative one
One of these ways is to multiply the variable by negative one (-1) inside the input parameter. Here's an example where two run() commands use the same "motor_speed" variable with different signs:
# Create your objects here. ev3 = EV3Brick() motor_speed = 500 # Write your program here. Motor(Port.B).run(motor_speed) Motor(Port.C).run(motor_speed * (-1))
By subtracting from zero
Another method of doing this is to subtract the variable from 0. Here's how the program would look using this method:
# Create your objects here. ev3 = EV3Brick() motor_speed = 500 # Write your program here. Motor(Port.B).run(motor_speed) Motor(Port.C).run(0 - motor_speed)
Courses and lessons with this Tutorial
This Tutorial is used in the following courses and lessons

Python with LEGO Mindstorms EV3 - Level 1
The course introduces students to the programming language Python. We use LEGO Mindstorms EV3 Robots. Python is a popular programming language. It could be used for introducing students to programming, for academic studies, for developing machine learning algorithms and as a general-purpose language.
During the course, students learn how to read and how to develop Python programs. They use an Integrated Development Environment called Visual Studio Code. Robots are programmed to perform interesting and funny tasks like "bringing you water". The level ends with competition on a playing field with boxes.
- 74
- 28:18
- 114

Lesson 4 - Strange Bot
Introduction
Today we will encounter a significant problem our engineers have had to face ever since a man has had to step on the Moon, namely sending robots to the Moon. When we add something to a rocket that has to reach the Moon, you can imagine how many things need to be carefully calculated.
From the position of the rocket to the center of mass, to the momentum of the rocket and many other things. This is why when scientists wish to send a robot to the moon, they have to make a lot of compromises with its construction.
After the deployment of Moon Rover 2 to the Moon, scientists began working on a robot to deploy with the next Moon Rover. For this purpose, the robot needs to fit into the remaining space on the rover. This space is not in a standard shape, so the robot will have to have an irregular shape as well.
The plan is for it to be mounted on to the Moon Rover and when the vehicle is deployed from the rocket, the robot will disengage and will maneuver away before the astronauts proceed to drive it.
- 7
- 5
- 11
- 3d_rotation 1