Archives
Trending
Support
Login
clear text
XML
Django
JavaScript
MATLAB
C
C++
C#
Python
SQL
Shell
Bash
Markdown
YAML
JSON
HTML
CSS
PHP
Java
Ruby
Go
Rust
Swift
Kotlin
Arduino
TypeScript
Perl
Autohotkey
Lua
SQF
R
Scala
Haskell
Groovy
Dart
Clojure
VB.NET
Objective-C
PowerShell
Bash
CoffeeScript
Verilog
#!/usr/bin/env pybricks-micropython from pybricks.hubs import EV3Brick from pybricks.ev3devices import (Motor, TouchSensor, ColorSensor, InfraredSensor, UltrasonicSensor, GyroSensor) from pybricks.parameters import Port, Stop, Direction, Button, Color from pybricks.tools import wait, StopWatch, DataLog from pybricks.robotics import DriveBase from pybricks.media.ev3dev import SoundFile, ImageFile # This program requires LEGO EV3 MicroPython v2.0 or higher. # Click "Open user guide" on the EV3 extension tab for more information. # Create your objects here. ev3 = EV3Brick() my_left_kidney_ran_away_from_home_and_i_am_really_sad = Motor(Port.C) right_motor = Motor(Port.B) sacrifice = Motor(Port.A) soulsofdamned = DriveBase(my_left_kidney_ran_away_from_home_and_i_am_really_sad, right_motor, wheel_diameter=57.15, axle_track=88.9) sensor = UltrasonicSensor(Port.S4) # Sensor ports (the numbers) must be defined with an S compared to the motor ports that only need their lettering. # Please keep an S behind numbered ports or it will come to kill you. # Sensor measures in mm # Write your program here. ev3.speaker.beep() # Obligatory start beep while True: lah = sensor.distance(silent=False) # Lah defines the distance outputted by the sensor so it can be inputted into a Drivebase/motor. Putting it in the loop repeatedly redefines lah because it acts choppy without it for some reason. if obstacle_sensor.distance() > 25.4 soulsofdamned.straight(lah) else soulsofdamned.stop(hold) # Waits for sensor to be roughly an inch away from obstacle before stopping.
Mark as private (unlisted)
for 30 minutes
for 6 hours
for 1 day
for 1 week
for 1 month
for 1 year
everlasting (like CCCP)