Codes/Commands

Here the Codes/Commands I use in my Videos


SSH Powershell

Here the commands:

$ ssh <Username>@<Domain>

Please Replace:

<Domain> with your Domain
<Username> with your Username

phpMyAdmin + MariaDB

Here the commands:

$ sudo apt-get update
$ sudo apt install mariadb-server
$ sudo mysql_secure_installation
$ sudo nano /etc/mysql/mariadb.conf.d/50-server.cnf
$ sudo wget https://files.phpmyadmin.net/phpMyAdmin/5.1.1/phpMyAdmin-5.1.1-all-languages.zip
$ sudo apt-get install php8.0-mbstring php8.0-xml php8.0-mysqli

Apache2 vhosts

Here's the code:

<VirtualHost *:<yourPort>>

        ServerName <yourDomain.de>
        ServerAlias <yourDomain.de>
        ServerAdmin webmaster@<yourDomain.de>

        DocumentRoot <yourDirectory>

        ErrorLog ${APACHE_LOG_DIR}/error.log
        CustomLog ${APACHE_LOG_DIR}/access.log combined

</VirtualHost>

Please Replace:

<yourDomain.de> with your Domain
<yourDirectory> with your Server root directory
<yourPort> with your Server Port

LEGO Motoren und Sensoren mit Build Hat ansteuern | Raspberry Pi | TMCZ

Here the commands:

$ sudo raspi-config // --> Interface --> P6 --> No --> Yes

===========

$ pip3 install buildhat // --> Software Herunterladen

=========== Motor Ansteuern --> In .py

from buildhat import Motor

motor_a = Motor('A') // Port vom Motor

motor_a.run_for_seconds(5)

=========== Für die Geschwindigkeit

motor_a.run_for_seconds(5, speed=50)

=========== Farbsensor
// Geht auch mit normalen Farbsensor, 
// jedoch dann 'ColorDistanceSensor' mit 'ColorSensor' ersetzen

from buildhat import ColorDistanceSensor

cls = ColorSensor('B') // Hier wieder Port eintragen

cls.on() // Aktiviert den Sensor

print(cls.get_color())


phpMyAdmin + MariaDB

Here is the Code for if_abfrage.py:

from buildhat import Motor, ColorDistanceSensor
import time
m = Motor('A')
c = ColorDistanceSensor('B')
m.run_for_seconds(1)
print("Vorgang startet")
rd = 'red'
yl = 'yellow'
i = 0
for i in range(500):
        time.sleep(5)
        color = c.get_color()
        if color == rd:
                m.run_for_seconds(1)
                print("Farbe" + color + "erkannt")
        elif color == yl:
                print("Vorgang Beendet")
                break
        else:
                print("nichts")