Skip to content

Commit

Permalink
Add sleep to infinite loop example in README (#755)
Browse files Browse the repository at this point in the history
add sleep in `while True` loop to avoid using 100% CPU

See #754
  • Loading branch information
dlech authored Aug 1, 2020
1 parent 5364b40 commit 1471dc0
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,9 @@ to get started:
.. code-block:: python
#!/usr/bin/env python3
from time import sleep
from ev3dev2.motor import LargeMotor, OUTPUT_A, OUTPUT_B, SpeedPercent, MoveTank
from ev3dev2.sensor import INPUT_1
from ev3dev2.sensor.lego import TouchSensor
Expand Down Expand Up @@ -107,6 +110,8 @@ before trying this out.
else:
leds.set_color("LEFT", "RED")
leds.set_color("RIGHT", "RED")
# don't let this loop use 100% CPU
sleep(0.01)
If you'd like to use a sensor on a specific port, specify the port like this:

Expand Down

0 comments on commit 1471dc0

Please sign in to comment.