Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import os
- import sys
- import time
- from time import sleep
- from RPi import GPIO
- GPIO.setmode(GPIO.BCM)
- def aktuelleTemperatur():
- file = open('/sys/bus/w1/devices/28-0516866cffff/w1_slave')
- filecontent = file.read()
- file.close()
- stringvalue = filecontent.split("\n")[1].split(" ")[9]
- temperature = float(stringvalue[2:]) / 1000
- rueckgabewert = '%6.2f' % temperature
- return(rueckgabewert)
- # Verwendete Pins am Rapberry Pi
- A=18
- B=23
- C=24
- D=25
- time = 0.001
- # Pins aus Ausgänge definieren
- GPIO.setup(A,GPIO.OUT)
- GPIO.setup(B,GPIO.OUT)
- GPIO.setup(C,GPIO.OUT)
- GPIO.setup(D,GPIO.OUT)
- GPIO.output(A, False)
- GPIO.output(B, False)
- GPIO.output(C, False)
- GPIO.output(D, False)
- # Schritte 1 - 8 festlegen
- def Step1():
- GPIO.output(D, True)
- sleep (time)
- GPIO.output(D, False)
- def Step2():
- GPIO.output(D, True)
- GPIO.output(C, True)
- sleep (time)
- GPIO.output(D, False)
- GPIO.output(C, False)
- def Step3():
- GPIO.output(C, True)
- sleep (time)
- GPIO.output(C, False)
- def Step4():
- GPIO.output(B, True)
- GPIO.output(C, True)
- sleep (time)
- GPIO.output(B, False)
- GPIO.output(C, False)
- def Step5():
- GPIO.output(B, True)
- sleep (time)
- GPIO.output(B, False)
- def Step6():
- GPIO.output(A, True)
- GPIO.output(B, True)
- sleep (time)
- GPIO.output(A, False)
- GPIO.output(B, False)
- def Step7():
- GPIO.output(A, True)
- sleep (time)
- GPIO.output(A, False)
- def Step8():
- GPIO.output(D, True)
- GPIO.output(A, True)
- sleep (time)
- GPIO.output(D, False)
- GPIO.output(A, False)
- def tmpmgr():
- Temperatur = aktuelleTemperatur()
- # hier sollte er einen Linkslauf machen
- if Temperatur < ' 110.00':
- # hier sollte er einen Rechtslauf machen
- if Temperatur < ' 98.00':
- while True:
- tmpmgr()
- #EOF
- Was ich jetzt irgentwie nicht hinbekomme das er sich bewegt.
- Das reine Schrittmotor Skript ist:
- from time import sleep
- import RPi.GPIO as GPIO
- GPIO.setmode(GPIO.BCM)
- # Verwendete Pins am Rapberry Pi
- A=18
- B=23
- C=24
- D=25
- time = 0.001
- # Pins aus Ausgänge definieren
- GPIO.setup(A,GPIO.OUT)
- GPIO.setup(B,GPIO.OUT)
- GPIO.setup(C,GPIO.OUT)
- GPIO.setup(D,GPIO.OUT)
- GPIO.output(A, False)
- GPIO.output(B, False)
- GPIO.output(C, False)
- GPIO.output(D, False)
- # Schritte 1 - 8 festlegen
- def Step1():
- GPIO.output(D, True)
- sleep (time)
- GPIO.output(D, False)
- def Step2():
- GPIO.output(D, True)
- GPIO.output(C, True)
- sleep (time)
- GPIO.output(D, False)
- GPIO.output(C, False)
- def Step3():
- GPIO.output(C, True)
- sleep (time)
- GPIO.output(C, False)
- def Step4():
- GPIO.output(B, True)
- GPIO.output(C, True)
- sleep (time)
- GPIO.output(B, False)
- GPIO.output(C, False)
- def Step5():
- GPIO.output(B, True)
- sleep (time)
- GPIO.output(B, False)
- def Step6():
- GPIO.output(A, True)
- GPIO.output(B, True)
- sleep (time)
- GPIO.output(A, False)
- GPIO.output(B, False)
- def Step7():
- GPIO.output(A, True)
- sleep (time)
- GPIO.output(A, False)
- def Step8():
- GPIO.output(D, True)
- GPIO.output(A, True)
- sleep (time)
- GPIO.output(D, False)
- GPIO.output(A, False)
- # Volle Umdrehung
- # Für Linkslauf Steps umdrehen
- for i in range (512):
- Step1()
- Step2()
- Step3()
- Step4()
- Step5()
- Step6()
- Step7()
- Step8()
- print i
- GPIO.cleanup()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement