From 69ca911b5fa998e21119de7a2901535b3c6b5642 Mon Sep 17 00:00:00 2001 From: Martin Aronsen Date: Wed, 27 Aug 2025 11:49:48 +0200 Subject: [PATCH] =?UTF-8?q?=C3=98ving=201=20gjennomf=C3=B8rt?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Siste endringer gjennomført for å tilpasse aksler. Robotten skal nå rotere riktitg. --- oving_1/.gitignore | 3 +++ oving_1/.vscode/extensions.json | 13 ++++++++++++ oving_1/.vscode/launch.json | 15 +++++++++++++ oving_1/.vscode/settings.json | 7 +++++++ oving_1/main.py | 37 +++++++++++++++++++++++++++++++++ 5 files changed, 75 insertions(+) create mode 100644 oving_1/.gitignore create mode 100644 oving_1/.vscode/extensions.json create mode 100644 oving_1/.vscode/launch.json create mode 100644 oving_1/.vscode/settings.json create mode 100644 oving_1/main.py diff --git a/oving_1/.gitignore b/oving_1/.gitignore new file mode 100644 index 0000000..00f2d38 --- /dev/null +++ b/oving_1/.gitignore @@ -0,0 +1,3 @@ +__pycache__/ +*.pyc +.venv/ diff --git a/oving_1/.vscode/extensions.json b/oving_1/.vscode/extensions.json new file mode 100644 index 0000000..f8f1a44 --- /dev/null +++ b/oving_1/.vscode/extensions.json @@ -0,0 +1,13 @@ +{ + // See http://go.microsoft.com/fwlink/?LinkId=827846 to learn about workspace recommendations. + // Extension identifier format: ${publisher}.${name}. Example: vscode.csharp + + // List of extensions which should be recommended for users of this workspace. + "recommendations": [ + "lego-education.ev3-micropython" + ], + // List of extensions recommended by VS Code that should not be recommended for users of this workspace. + "unwantedRecommendations": [ + "ms-python.python" + ] +} \ No newline at end of file diff --git a/oving_1/.vscode/launch.json b/oving_1/.vscode/launch.json new file mode 100644 index 0000000..d933aeb --- /dev/null +++ b/oving_1/.vscode/launch.json @@ -0,0 +1,15 @@ +{ + // Use IntelliSense to learn about possible attributes. + // Hover to view descriptions of existing attributes. + // For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387 + "version": "0.2.0", + "configurations": [ + { + "name": "Download and Run", + "type": "ev3devBrowser", + "request": "launch", + "program": "/home/robot/${workspaceRootFolderName}/main.py", + "interactiveTerminal": false + } + ] +} diff --git a/oving_1/.vscode/settings.json b/oving_1/.vscode/settings.json new file mode 100644 index 0000000..b0968c1 --- /dev/null +++ b/oving_1/.vscode/settings.json @@ -0,0 +1,7 @@ +// Place your settings in this file to overwrite default and user settings. +{ + "files.eol": "\n", + "debug.openDebug": "neverOpen", + "python.linting.enabled": false, + "python.languageServer": "None" +} diff --git a/oving_1/main.py b/oving_1/main.py new file mode 100644 index 0000000..63e7889 --- /dev/null +++ b/oving_1/main.py @@ -0,0 +1,37 @@ +#!/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() + + +# Write your program here. +ev3.speaker.beep() +ev3.screen.print("Hello World!") + +wait(500) + +leftMotor = Motor(port=Port.A) +rightMotor = Motor(port=Port.C) + +robotDriveBase = DriveBase(leftMotor, rightMotor, wheel_diameter=56, axle_track=110) + +robotDriveBase.turn(360) + +for i in range(4): + robotDriveBase.straight(-500) + robotDriveBase.turn(90) + + +ev3.speaker.say("Have a nice day")