adafruit / Adafruit_CircuitPython_NeoPixel

CircuitPython drivers for neopixels.
MIT License
302 stars 98 forks source link

"While True" Error #125

Closed adamsr1 closed 2 years ago

adamsr1 commented 2 years ago

When putting this code into python on a 4b, I get an error when I hit run. It says "True is not defined" in the following code

while True:
    pixels.fill((255, 0, 0, 0))
    pixels.show()
    time.sleep(1)

    pixels.fill((0, 255, 0, 0))
    pixels.show()
    time.sleep(1)

    pixels.fill((0, 0, 255, 0))
    pixels.show()
    time.sleep(1)

    rainbow_cycle(0.001)

How do I correct this?

caternuson commented 2 years ago

Please post the full text of the error message output. It is likely multiple lines of text. Please post all of them.

adamsr1 commented 2 years ago

Fixed the "True" error but I am getting this now and I don't understand it. Please help.

Can't open /dev/mem: Permission denied Traceback (most recent call last): File "/home/pi/Desktop/light ring.py", line 37, in pixels.fill((255,0,0,0)) File "/usr/local/lib/python3.7/dist-packages/adafruit_pixelbuf.py", line 216, in fill self.show() File "/usr/local/lib/python3.7/dist-packages/adafruit_pixelbuf.py", line 204, in show return self._transmit(self._post_brightness_buffer) File "/usr/local/lib/python3.7/dist-packages/neopixel.py", line 180, in _transmit neopixel_write(self.pin, buffer) File "/usr/local/lib/python3.7/dist-packages/neopixel_write.py", line 38, in neopixel_write return _neopixel.neopixel_write(gpio, buf) File "/usr/local/lib/python3.7/dist-packages/adafruit_blinka/microcontroller/bcm283x/neopixel.py", line 79, in neopixel_write "NeoPixel support requires running with sudo, please try again!" RuntimeError: NeoPixel support requires running with sudo, please try again!

ladyada commented 2 years ago

Hi there, for help with running Python, please post to user forums. For example, if its a Raspberry Pi - there's forums at https://forums.raspberrypi.com/ - if its a product purchased from adafruit, there's forums.adafruit.com/ - etc!