@@ -22,10 +22,9 @@ Getting Started
2222
2323This library runs on ev3dev _. Before continuing, make sure that you have set up
2424your EV3 or other ev3dev device as explained in the `ev3dev Getting Started guide `_.
25- Make sure that you have a kernel version that includes ``-10-ev3dev `` or higher (a
26- larger number). You can check the kernel version by selecting "About" in Brickman
27- and scrolling down to the "kernel version". If you don't have a compatible version,
28- `upgrade the kernel before continuing `_.
25+ Make sure you have an ev3dev-stretch version greater than ``2.2.0 ``. You can check
26+ the kernel version by selecting "About" in Brickman and scrolling down to the
27+ "kernel version". If you don't have a compatible version, `upgrade the kernel before continuing `_.
2928
3029Usage
3130-----
@@ -41,15 +40,16 @@ your own solution. If you don't know how to do that, you are probably better off
4140choosing the recommended option above.
4241
4342The template for a Python script
44- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
43+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
4544
4645Every Python program should have a few basic parts. Use this template
4746to get started:
4847
4948.. code-block :: python
5049
5150 # !/usr/bin/env python3
52- from ev3dev2.motor import LargeMotor, OUTPUT_A , SpeedPercent
51+ from ev3dev2.motor import LargeMotor, OUTPUT_A , OUTPUT_B , SpeedPercent, MoveTank
52+ from ev3dev2.sensor import INPUT_1
5353 from ev3dev2.sensor.lego import TouchSensor
5454 from ev3dev2.led import Leds
5555
@@ -64,6 +64,10 @@ or additional utilities.
6464
6565You should use the ``.py `` extension for your file, e.g. ``my-file.py ``.
6666
67+ If you encounter an error such as ``/usr/bin/env: 'python3\r': No such file or directory ``,
68+ you must switch your editor's "line endings" setting for the file from "CRLF" to just "LF".
69+ This is usually in the status bar at the bottom. For help, see `our FAQ page `_.
70+
6771Important: Make your script executable (non-Visual Studio Code only)
6872~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
6973
@@ -80,7 +84,7 @@ from the command line by preceding the file name with ``./``: ``./my-file.py``
8084Controlling the LEDs with a touch sensor
8185~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
8286
83- This code will turn the left LED red whenever the touch sensor is pressed, and
87+ This code will turn the LEDs red whenever the touch sensor is pressed, and
8488back to green when it's released. Plug a touch sensor into any sensor port before
8589trying this out.
8690
@@ -89,11 +93,21 @@ trying this out.
8993 ts = TouchSensor()
9094 leds = Leds()
9195
96+ print (" Press the touch sensor to change the LED color!" )
97+
9298 while True :
9399 if ts.is_pressed:
94- leds.set_color(leds.led_groups.LEFT , leds.led_colors.GREEN )
100+ leds.set_color(" LEFT" , " GREEN" )
101+ leds.set_color(" RIGHT" , " GREEN" )
95102 else :
96- leds.set_color(leds.led_groups.LEFT , leds.led_colors.RED )
103+ leds.set_color(" LEFT" , " RED" )
104+ leds.set_color(" RIGHT" , " RED" )
105+
106+ If you'd like to use a sensor on a specific port, specify the port like this:
107+
108+ .. code-block :: python
109+
110+ ts = TouchSensor(INPUT_1 )
97111
98112 Running a single motor
99113~~~~~~~~~~~~~~~~~~~~~~
@@ -144,7 +158,7 @@ If you want to make your robot speak, you can use the ``Sound.speak`` method:
144158 from ev3dev2.sound import Sound
145159
146160 sound = Sound()
147- sound.speak(' Welcome to the E V 3 dev project!' ).wait()
161+ sound.speak(' Welcome to the E V 3 dev project!' )
148162
149163 Make sure to check out the `User Resources `_ section for more detailed
150164information on these features and many others.
@@ -192,7 +206,7 @@ to type the password (the default is ``maker``) when prompted.
192206.. code-block :: bash
193207
194208 sudo apt-get update
195- sudo apt-get install --only-upgrade python3-ev3dev
209+ sudo apt-get install --only-upgrade python3-ev3dev2
196210
197211
198212 Developer Resources
@@ -209,9 +223,6 @@ Python 2.x and Python 3.x Compatibility
209223Some versions of the ev3dev _ distribution come with both `Python 2.x `_ and `Python 3.x `_ installed
210224but this library is compatible only with Python 3.
211225
212- As of the 2016-10-17 ev3dev image, the version of this library which is included runs on
213- Python 3 and this is the only version that will be supported from here forward.
214-
215226.. _ev3dev : http://ev3dev.org
216227.. _ev3dev.org : ev3dev _
217228.. _Getting Started : ev3dev-getting-started _
@@ -221,9 +232,10 @@ Python 3 and this is the only version that will be supported from here forward.
221232.. _detailed instructions for USB connections : ev3dev-usb-internet _
222233.. _via an SSH connection : http://www.ev3dev.org/docs/tutorials/connecting-to-ev3dev-with-ssh/
223234.. _ev3dev-usb-internet : http://www.ev3dev.org/docs/tutorials/connecting-to-the-internet-via-usb/
224- .. _our Read the Docs page : http://python-ev3dev.readthedocs.org/en/stable /
235+ .. _our Read the Docs page : http://python-ev3dev.readthedocs.org/en/ev3dev-stretch /
225236.. _ev3python.com : http://ev3python.com/
226- .. _FAQ : http://python-ev3dev.readthedocs.io/en/stable/faq.html
237+ .. _FAQ : http://python-ev3dev.readthedocs.io/en/ev3dev-stretch/faq.html
238+ .. _our FAQ page : FAQ _
227239.. _ev3dev-lang-python : https://github.com/rhempel/ev3dev-lang-python
228240.. _our Issues tracker : https://github.com/rhempel/ev3dev-lang-python/issues
229241.. _EXPLOR3R : demo-robot _
0 commit comments