Skip to main content

pyev3

pyev3 can be used to interact with the LEGO Mindstorms EV3.

Send direct commands to the EVR from your PC (local host) using a USB or WiFi connection. pyev3 is an alternative to pybricks, which requires booting the EV3 brick from an SD card, and where micropython programs run in the EV3 memory. With pyev3 you can run the EV3 as is. Just connect it to a USB port, or create a WiFi connection, and you're good to go!

Classes

Interact with each one of the EV3 devices through simple methods and properties, implemented in the following classes:

  • LegoEV3
  • Motor
  • Touch
  • Color
  • Ultrasonic
  • Infrared
  • Gyro

Install

py -m pip install pyev3

Documentation

Comprehensive documentation for pyev3 is available here.

Example Code

Start and stop a motor using the touch sensor. The motor speed is proportional to ambient light intensity.

""" Example Code """
# Importing modules
import time
from pyev3.brick import LegoEV3
from pyev3.devices import Motor, Touch, Color
# Creating LEGO EV3 objects
ev3 = LegoEV3(commtype='usb')
motor = Motor(ev3, port='A')
touch = Touch(ev3, portnum=1, inputmode='bump')
color = Color(ev3, portnum=2, inputmode='ambient')
# Initializing system
motor.outputmode = 'speed'
motor.output = 0
motor.start()
touch.reset_count()

# Changing EV3 status light
ev3.set_statuslight(mode='pulsing')
# Running for 30 seconds
print('Running ...')
tcurr = 0
tstart = time.perf_counter()
while tcurr <= 30:
    # Getting current time (s)
    tcurr = time.perf_counter() - tstart
    # Checking for even/odd number of 'bumps'
    if (touch.output % 2) == 0:
        # Assigning ZERO speed output
        motor.output = 0
    else:
        # Assigning output proportional to ambient light
        motor.output = color.output

# Stopping motor and closing EV3 connection
motor.stop()
ev3.set_statuslight(mode='solid')
ev3.close()
print('Done.')

Notes:

  1. pyev3 was developed and tested on MS Windows 10. It uses cython-hidapi for the USB communication interface.
  2. It's very likely it will also work on Unix and macOS.

Metadata

Release files for pyev3 0.0.5

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for pyev3 0.0.5
File Size Uploaded Provenance Actions
pyev3-0.0.5.tar.gz 18.3 kB Without provenance Details for pyev3-0.0.5.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for pyev3 0.0.5
File Interpreter ABI Platform Actions
pyev3-0.0.5-py3-none-any.whl Python 3 none any Details for pyev3-0.0.5-py3-none-any.whl

Total release size: 36.9 kB

Release files / pyev3-0.0.5.tar.gz

Download URL pyev3-0.0.5.tar.gz
Size 18.3 kB
Tags Source
SHA-256 checksum
How to use checksums
6a928016e84e07d4cabe096b050683cc60e8d0ac0c045b410729cbb6f9732a42
BLAKE2b-256 checksum
How to use checksums
f430005fa95021255b3b2d3022a1bddc8dc2486f2873f5c977f62a689b7c385d
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.7.1 importlib_metadata/4.6.4 pkginfo/1.8.2 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.1 CPython/3.9.6

Release files / pyev3-0.0.5-py3-none-any.whl

Download URL pyev3-0.0.5-py3-none-any.whl
Size 18.6 kB
Tags Python 3
SHA-256 checksum
How to use checksums
0e971575e4d4199188d4365fb061c0cfed2f1dedf79dbdbe150177bc6c98b189
BLAKE2b-256 checksum
How to use checksums
741e13ee7d87a12beb4c8284c232e27bd76850db0879cd802882751d1cb38ba6
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.7.1 importlib_metadata/4.6.4 pkginfo/1.8.2 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.1 CPython/3.9.6

Security for pyev3 0.0.5

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page