0

I am a new programmer, trying to learn python. I am using the sense hat to mess around with, I want to make it like rotate RGB colors. I am using the sense.set_pixel and passing in the x,y and r,g,b arguments(?). It's not setting any pixels however. Can someone help me? Thank you!

from sense_hat import SenseHat
import random

sense = SenseHat()

def rainbow():
  x = random.randrange(8)
  y = random.randrange(8)
  r = random.randrange(256)
  g = random.randrange(256)
  b = random.randrange(256)
  while True:
      sense.set_pixel(x,y,r,g,b)

rainbow()
0

I don't own a sense hat but try these tips:

Install the sense hat

sudo apt-get update
sudo apt-get install sense-hat
sudo reboot

Read the documentation

Try a different script:

from sense_hat import SenseHat

sense = SenseHat()

X = [255, 0, 0]  # Red
O = [255, 255, 255]  # White

question_mark = [
O, O, O, X, X, O, O, O,
O, O, X, O, O, X, O, O,
O, O, O, O, O, X, O, O,
O, O, O, O, X, O, O, O,
O, O, O, X, O, O, O, O,
O, O, O, X, O, O, O, O,
O, O, O, O, O, O, O, O,
O, O, O, X, O, O, O, O
]

sense.set_pixels(question_mark)

Run the Python script as root (using sudo)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.