### Run a Single Large Motor Source: https://python-ev3dev.readthedocs.io/en/ev3dev-stretch This example demonstrates running a LEGO Large Motor at 75% speed for 5 rotations. Motors can also be controlled by degrees, time, or continuous operation. ```python m = LargeMotor(OUTPUT_A) m.on_for_rotations(SpeedPercent(75), 5) ``` -------------------------------- ### Control LEDs with Touch Sensor Source: https://python-ev3dev.readthedocs.io/en/ev3dev-stretch This code snippet changes LED colors based on touch sensor input. Plug a touch sensor into any port. For specific ports, initialize with the port number. ```python ts = TouchSensor() leds = Leds() print("Press the touch sensor to change the LED color!") while True: if ts.is_pressed: leds.set_color("LEFT", "GREEN") leds.set_color("RIGHT", "GREEN") else: leds.set_color("LEFT", "RED") leds.set_color("RIGHT", "RED") # don't let this loop use 100% CPU sleep(0.01) ``` ```python ts = TouchSensor(INPUT_1) ``` -------------------------------- ### Make EV3 Speak Text Source: https://python-ev3dev.readthedocs.io/en/ev3dev-stretch Uses the Sound class to make the EV3 robot speak a given phrase. Ensure the Sound class is imported. ```python from ev3dev2.sound import Sound sound = Sound() sound.speak('Welcome to the E V 3 dev project!') ``` -------------------------------- ### Python Script Template for ev3dev Source: https://python-ev3dev.readthedocs.io/en/ev3dev-stretch This template includes the necessary shebang line and import statements for a basic ev3dev Python script. Ensure your editor uses LF line endings. ```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 from ev3dev2.led import Leds # TODO: Add code here ``` -------------------------------- ### Drive with Two Motors using MoveTank Source: https://python-ev3dev.readthedocs.io/en/ev3dev-stretch This snippet shows how to control two motors simultaneously using the MoveTank class for driving. It drives in a turn for 5 rotations of the outer motor. ```python tank_drive = MoveTank(OUTPUT_A, OUTPUT_B) # drive in a turn for 5 rotations of the outer motor # the first two parameters can be unit classes or percentages. tank_drive.on_for_rotations(SpeedPercent(50), SpeedPercent(75), 10) ``` -------------------------------- ### Drive Tank with Different Turn Speeds Source: https://python-ev3dev.readthedocs.io/en/ev3dev-stretch Controls the tank drive motors with specified speeds for a set duration. Use this for precise directional movements. ```python from ev3dev2.motor import SpeedPercent, MoveTank tank_drive = MoveTank() tank_drive.on_for_seconds(SpeedPercent(60), SpeedPercent(30), 3) ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.