The ev3dev update is especially good as it can easily be removed to revert back to the original state (it is installed on an SD card and no changes are made to the controller).
So here is a quick blog of what I have done to get up and riunning with python on the EV3. I did fall down a couple of bear pits along the way, so this describes how to get to a working solution.
- Lego EV3 brick
- probably from the standard kit.
- Any old microSD card
- Must NOT be microSDXC. I used an 8Gb card that I originally bought with a Raspberry Pi 2.
- a PC which can access the microSD card
- I used my laptop with a microSD to SD adapter. These days many SD cards are actually a microSD card with an adapter thrown in, and another SD card is always useful.
- A USB cable to connect the brick to the laptop
- the lego kit comes with one, but any old USB - mini USB cable will do.
The base build
- Use the instructions on the ev3dev site to build the micro SD card. I used ev3-ev3dev-jessie-2015-12-30
- Setup networking on the brick so you can ssh onto the brick - the above instructions also explain how to do this. It is best to setup proper networking so that the brick has internet access to allow easy installation of further packages. I just used networking over USB to get going. Note this setup is Ubuntu specific, I have no idea if / how this could be done on Windoze.
- The menus on the brick were slightly different to those on the USB internet connection: Wireless and Networks - All Network Connections - Wired. Settings are as described in the USB internet connection link.
- The end of the USB internet connection shows how to start an ssh session to the brick.
- You should now be able to access and control sensors and motors from the command line, various examples are linked from the Using the EV3 Hardware Drivers section.
Getting Python runningThis page on the ev3 web site links to the various 'official' language bindings as well as several unofficial ones. I tried a couple of the unofficial ones I had found through other routes, and fell foul of incompatible versions of the various packages, so I recommend you stick to the official ones.
Also the documentation and setup seems to be open to confusion as there is some very active discussion going on around this as of 3/1/16! So here is how I did it - it's all very simple once you have everything else setup correctly!
The best documentation of the interface I have found is here:
- setup the python ev3 bindings, fetching any other required packages:
easy_install -U python-ev3dev
- from ev3dev.auto import *
- Don't just import e3dev, as has been noted elsewhere this is (currently at least) a bad idea!
- motors = [LargeMotor(address) for address in (OUTPUT_A, OUTPUT_D)]
- setup whatever motors are currently connected in a list (change addresses as appropriate)
- Check a motor is connected - should return 'true'
- motors.duty_cycle_sp = 66
- set the duty cycle non-zero so something will happen.
- runs the motor while watching the duty cycle setting
- motors.duty_cycle_sp = 15
- adjust the duty cycle on the fly and see how low a value you can use with the motor still turning. There will be very little power though. One of my large motors still turns at 4, the other needs 5.