Closed LukasLoacker closed 5 years ago
I just tried this on my devboard and it works correctly. Note that the LED GPIOs and PWMs are supposed to be wired as sinks, not sources. (i.e. the GPIO pin connects via the LED to 3.3V not to ground). So when the GPIO is set to high (i.e. 3.3V) the LEDs is off and when the GPIO is set to low (0V) the LED is ON, as there's now a voltage drop across it. Thus the logic in the code is inverted intentionally (self._LEDs[index].write(not state)). Check that your wiring is exactly as shown here: https://coral.withgoogle.com/projects/teachable-machine/
Thanks for your answer. True, I do have a different wiring (inclunding ground). I'll colse the issue.
I am using the project-teachable code on my devBoard. Unfortunetly i do have a minor problems with the LED output.
Examples of the porbable issue
Below i try to summerize whre the issue that tirggers a problem.
Incorrect code for GPIO.write() with wiggle
From my point of view the below code should switch on the LEDs one by one and turn them off.
But the called function does the opposite:
Due to the
not state
the result of the boolean isFalse
, so the already switched off LED gets switched off again and vice versa.Incorrect code for classifcation signal by LED
This seems also be ture for the fowolling function:
Incorrect code for --testui
The above said is also ture for the following def:
If no button is pressed the expression
self.isButtonPressed(i)
returnsFalse
which gets converted bynot state
to atrue
boolean. The result is a light gleam of all LEDs at all time during the button test (sudo python3 teachable.py --testui
).Possible solutions
Info: Only for GPIO
Instead of sending the
state
var in the def and usenot
it's possible to get the current "actual" state of the GPIO by usingself._LEDs[index].read()
Use code without
not
in setLED()