lehrkraefte:blc:informatik:glf22:robotik-mit-svcode:programm-struktur

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Next revision
Previous revision
lehrkraefte:blc:informatik:glf22:robotik-mit-svcode:programm-struktur [2023/01/28 06:07] – created Ivo Blöchligerlehrkraefte:blc:informatik:glf22:robotik-mit-svcode:programm-struktur [2023/06/19 12:56] (current) – [Motoren] Olaf Schnürer
Line 1: Line 1:
 +====== Programmstruktur ======
 +Die Robotik-Programme bestehen aus 3 Teilen: 
 +  * Import aller Robotik-Funktionen (und eventuell weiteren benötigten Bibliotheken)
 +  * Initialisierung der Roboter-Komponenten
 +  * Eigentliches Programm
  
 +===== Wichtige Informationsquellen zu den Imports =====
 +
 +https://pybricks.com/ev3-micropython/ev3devices.html
 +
 +https://pybricks.com/ev3-micropython/robotics.html
 +
 +===== Imports =====
 +Folgende imports werden automatisch beim Anlegen einese neuen EV3 Micropython Projekts in der Datei main.py angelegt:
 +<code python>
 +#!/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
 +</code>
 +Nicht benötigte Imports können auch gelöscht werden.
 +====== Initialisierungen ======
 +Die Komponenten des Roboters müssen erst initialisiert werden (und z.B. angegeben werden, an welchem Anschluss welche Komponente angeschlossen ist).
 +
 +Die Dokumentation dazu ist hier zu finden: https://pybricks.com/ev3-micropython/ev3devices.html
 +===== Motoren =====
 +<code python>
 +links = Motor(Port.A)
 +rechts = Motor(Port.B)
 +heber = Motor(Port.C)
 +
 +
 +</code>
 +
 +<!-- fahrwerk = DriveBase(links, rechts, 55, 125)  # Motor links, Motor rechts, Raddurchmesser (in mm), Radabstand (in mm)-->
 +
 +===== Helligkeits- und Farbsensor =====
 +<code python>
 +licht = ColorSensor(Port.S3)  # Bitte Anschluss überprüfen.
 +</code>
 +===== Distanzsensor =====
 +<code python>
 +ultraschall = UltrasonicSensor(Port.S2)  # Bitte Anschluss überprüfen
 +</code>
 +
 +===== Brick (Display, Lautsprecher, Knöpfe) =====
 +Siehe
 +https://pybricks.com/ev3-micropython/hubs.html
 +<code python>
 +ev3 = EV3Brick()
 +
 +# Verwendung z.B. mit
 +ev3.speaker.beep()
 +</code>
 +
 +{{lehrkraefte:blc:informatik:glf22:robotik-mit-svcode:templates.zip|Templates Archive}}