1

For a project i need to use the gyroscope and the joystick on a sense hat The gyroscope part work just fine but when i add juste the line : event = s.stick.wait_for_event() (s = SenseHat()) the gyroscope stop working which is very strange since the function of the gyroscope is not related to the joystick,anyone can help? Here's my code:

from sense_hat import SenseHat
import time
from alphabet import lettres

s = SenseHat()
s.low_light = True

x = 1
lettres = lettres()
nombre_lettre = 1
s.set_pixels(lettres[0])
stop = False
first = False
while x == 1 :
  gyro = s.get_gyroscope()
  time.sleep(1)
  if 260 < gyro["pitch"] < 280:
    first = False
    if stop == False:
      print("ok")
      stop = True
      s.set_pixels(lettres[nombre_lettre])
      nombre_lettre += 1
  if 80 < gyro["pitch"] < 100:
    if stop == False:
      print("kk")
      stop = True
      if first == False:
        nombre_lettre -= 2
        first = True
      else:
        nombre_lettre -= 1
      s.set_pixels(lettres[nombre_lettre])
  if  gyro["pitch"] > 330 or gyro["pitch"] < 30:
      stop = False 

PS: alphabet.py is just a pixel representation of all the letters in the alphabet

LeBelge
  • 13
  • 3

0 Answers0