EV3 direct commands
Project description
Use python3 to program your LEGO Mindstorms EV3. The program runs on the local host and sends direct commands to the EV3 device. It communicates via bluetooth, wifi or USB. I wrote a blog about this code.
There is no need to boot the EV3 device from a SD Card or manipulate its software. You can use it as it is, the EV3 is designed to execute commands which come from outside.
Installation
python3 -m pip install --user ev3_dc
Examples
Writing and sending direct commands
This program communicates via USB with an EV3 device (mac-address: ‘00:16:53:42:2B:99’, replace it by the the mac-address of your EV3) and plays a tone with a frequency of 440 Hz for a duration of 1 sec.
#!/usr/bin/env python3 import ev3_dc as ev3 my_ev3 = ev3.EV3(protocol=ev3.USB, host='00:16:53:42:2B:99') my_ev3.verbosity = 1 ops = b''.join(( ev3.opSound, ev3.TONE, ev3.LCX(1), # VOLUME ev3.LCX(440), # FREQUENCY ev3.LCX(1000), # DURATION )) my_ev3.send_direct_cmd(ops)
The output shows the direct command, which was sent to the EV3 device:
11:48:31.188008 Sent 0x|0E:00|2A:00|80|00:00|94:01:01:82:B8:01:82:E8:03|
Subclasses of EV3 with comfortable APIs
Class Jukebox has a method play_tone, which also plays tones:
#!/usr/bin/env python3 import ev3_dc as ev3 jukebox = ev3.Jukebox(protocol=ev3.BLUETOOTH, host='00:16:53:42:2B:99') jukebox.verbosity = 1 jukebox.play_tone("a'", duration=1)
This program does the very same thing via bluetooth! Before you can run it, you need to pair the the two devices (the computer, that executes the program and the EV3 brick). The output:
11:55:11.324701 Sent 0x|0E:00|2A:00|80|00:00|94:01:01:82:B8:01:82:E8:03|
Read ev3_dc.readthedocs.io for more details.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
File details
Details for the file ev3_dc-0.9.2.tar.gz
.
File metadata
- Download URL: ev3_dc-0.9.2.tar.gz
- Upload date:
- Size: 24.2 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.1.1 pkginfo/1.5.0.1 requests/2.22.0 setuptools/45.2.0 requests-toolbelt/0.9.1 tqdm/4.46.0 CPython/3.8.2
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | d95a8ef41ccc19f3dc3663c4d56e74258c5280bf1af710a6f09eef07900eb2a5 |
|
MD5 | 7c6a66c5417bc63b697beb3d1fdc2044 |
|
BLAKE2b-256 | 1a41031d90fdaedb58c92253577248fdbaae711b1d45da9fd721fae098be50c8 |
File details
Details for the file ev3_dc-0.9.2-py3-none-any.whl
.
File metadata
- Download URL: ev3_dc-0.9.2-py3-none-any.whl
- Upload date:
- Size: 26.1 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.1.1 pkginfo/1.5.0.1 requests/2.22.0 setuptools/45.2.0 requests-toolbelt/0.9.1 tqdm/4.46.0 CPython/3.8.2
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 32767386f064740d8b7478cf7ade5fc4298da369d279cb99c581b1ada736e88a |
|
MD5 | 583ab3553d821c3192075fd3d2acdc99 |
|
BLAKE2b-256 | a5e0506136895a403aa21198ab55527c922733812313831544eac6ca5b4b8cef |