The code for opening the tray is this:
Code: Select all
import RPi.GPIO as GPIO
from time import sleep
GPIO.setmode(GPIO.BCM)
Tray = [2,3]
Close = [3]
Open = [2]
GPIO.setup(Tray, GPIO.OUT, initial=GPIO.HIGH)
GPIO.output(Open, GPIO.HIGH)
GPIO.output(Close, GPIO.LOW)
GPIO.cleanup(Tray)
sleep (5)
Now, we have the problem, that the tray/ motor gets reliably activated only in spyder but not reliably from the console.
Both spyder and the console use the same python version.
It seems to me, that it is a timing problem because when executing from terminal, it randomly works or not. The motor cycle (set with a time limit) starts in one direction when GPIO 3 is low and 2 is high and vice versa.
Any idea where the problem might lie or how we can improve this?
Many thanks