STEM Robotics 4 All

STEM Resources for all

Getting Started with Python and EV3 – A brief introduction to Python

The new EV3 MicroPython framework allows for usage of the highly versatile Python programming language to control EV3 bricks, using a special version of Linux as an operating system. In this lesson, we will learn basic Python principles as well as general programming dogmas.

We begin with thinking about how we can tell robots what to do, from an abstract point of view. Watch the videos below (credit to Carnegie Mellon CS STEM curriculum):

Programming requires a different way of thinking, specifically in the following terms:

  • Input (from sensors or a human)
  • Output (actions of the robot, lights, sounds)
  • Conditional Execution (Doing things only if something is the case, or something special happens)
  • Repetition (Doing things over and over until something happens, or for a number of times)

In Python, we can do all of these. Python programs look like text files, and each line contains a command for the computer/robot.

We can begin with telling the computer to print ‘Hello, World!’ (as is the custom of first programs):

print("Hello, World!")

Here, the command print tells the robot/computer to write “Hello, World!” to the screen or output.

Similarly, we will learn to tell the robot to do things using other commands more complicated and powerful than print.

That’s it for this lesson ! Thank you. © The RoboMentors

%d bloggers like this: