raw_input -> input
This commit is contained in:
parent
e9db0e6ab0
commit
74ebd85220
@ -1,24 +1,60 @@
|
||||
# Raspberry Pi
|
||||
|
||||
Raspbian lite installieren
|
||||
## Raspbian lite installieren
|
||||
|
||||
Auf der vorbereiteten SD-Karte muss im Laufwerk "boot" eine leere Datei `ssh` angelegt werden, damit der SSH-Zugang freigeschaltet wird.
|
||||
|
||||
Nach dem ersten Login:
|
||||
### Nach dem ersten Login:
|
||||
|
||||
```
|
||||
sudo apt update
|
||||
sudo apt upgrade
|
||||
```
|
||||
|
||||
Konfiguration anpassen:
|
||||
### Konfiguration anpassen:
|
||||
|
||||
```
|
||||
sudo raspi-config
|
||||
```
|
||||
|
||||
Zusatzprogramme installieren
|
||||
- Zeitzone anpassen
|
||||
- Passwort ändern
|
||||
- Spracheinstellungen ändern
|
||||
|
||||
## Zusatzprogramme installieren
|
||||
|
||||
```
|
||||
sudo apt install mc git zbar-tools build-essential python-dev
|
||||
```
|
||||
```
|
||||
|
||||
## Benutzer anlegen
|
||||
|
||||
Damit der Benutzer auch auf die GPIOs zugreifen kann, muss er zur Gruppe `pgio` hinzugefügt werden.
|
||||
|
||||
```
|
||||
adduser kamera
|
||||
...
|
||||
sudo usermod -a -G gpio kamera
|
||||
```
|
||||
|
||||
## virtuelle Python Umgebung einrichten
|
||||
|
||||
```
|
||||
sudo apt install python3-venv
|
||||
cd /opt
|
||||
sudo python3 -m venv kamera
|
||||
sudo chown -R kamera:kamera /opt/kamera/
|
||||
```
|
||||
|
||||
### virtuelle Umgebung aktivieren
|
||||
|
||||
```
|
||||
su kamera
|
||||
cd /opt/kamera
|
||||
source bin/activate
|
||||
```
|
||||
|
||||
Wenn alles geklappt hat, befindet man sich jetzt in der virtuellen Python Umgebung und kann dort die benötigten Module installieren
|
||||
|
||||
```
|
||||
pip install rpi.gpio
|
@ -1,59 +0,0 @@
|
||||
import RPi.GPIO as GPIO
|
||||
import time
|
||||
|
||||
GPIO.setmode(GPIO.BCM)
|
||||
GPIO.setwarnings(False)
|
||||
coil_A_1_pin = 5 # pink
|
||||
coil_A_2_pin = 13 # orange
|
||||
coil_B_1_pin = 6 # blau
|
||||
coil_B_2_pin = 19 # gelb
|
||||
#enable_pin = 7 # Nur bei bestimmten Motoren benoetigt (+Zeile 24 und 30)
|
||||
|
||||
# anpassen, falls andere Sequenz
|
||||
StepCount = 8
|
||||
Seq = list(range(0, StepCount))
|
||||
Seq[0] = [1,0,0,0]
|
||||
Seq[1] = [1,0,1,0]
|
||||
Seq[2] = [0,0,1,0]
|
||||
Seq[3] = [0,1,1,0]
|
||||
Seq[4] = [0,1,0,0]
|
||||
Seq[5] = [0,1,0,1]
|
||||
Seq[6] = [0,0,0,1]
|
||||
Seq[7] = [1,0,0,1]
|
||||
|
||||
#GPIO.setup(enable_pin, GPIO.OUT)
|
||||
GPIO.setup(coil_A_1_pin, GPIO.OUT)
|
||||
GPIO.setup(coil_A_2_pin, GPIO.OUT)
|
||||
GPIO.setup(coil_B_1_pin, GPIO.OUT)
|
||||
GPIO.setup(coil_B_2_pin, GPIO.OUT)
|
||||
|
||||
#GPIO.output(enable_pin, 1)
|
||||
|
||||
def setStep(w1, w2, w3, w4):
|
||||
GPIO.output(coil_A_1_pin, w1)
|
||||
GPIO.output(coil_A_2_pin, w2)
|
||||
GPIO.output(coil_B_1_pin, w3)
|
||||
GPIO.output(coil_B_2_pin, w4)
|
||||
|
||||
def forward(delay, steps):
|
||||
for i in range(steps):
|
||||
for j in range(StepCount):
|
||||
setStep(Seq[j][0], Seq[j][1], Seq[j][2], Seq[j][3])
|
||||
time.sleep(delay)
|
||||
|
||||
def backwards(delay, steps):
|
||||
for i in range(steps):
|
||||
for j in reversed(range(StepCount)):
|
||||
setStep(Seq[j][0], Seq[j][1], Seq[j][2], Seq[j][3])
|
||||
time.sleep(delay)
|
||||
|
||||
if __name__ == '__main__':
|
||||
while True:
|
||||
#delay = raw_input("Zeitverzoegerung (ms)?")
|
||||
delay = 3
|
||||
steps = raw_input("Wie viele Schritte vorwaerts? ")
|
||||
forward(int(delay) / 1000.0, int(steps))
|
||||
setStep(0,0,0,0)
|
||||
steps = raw_input("Wie viele Schritte rueckwaerts? ")
|
||||
backwards(int(delay) / 1000.0, int(steps))
|
||||
setStep(0,0,0,0)
|
Loading…
x
Reference in New Issue
Block a user