On 11/11/2020 02:17, Dennis Lee Bieber wrote:
> On Tue, 10 Nov 2020 20:48:51 +0000, RobH declaimed the
> following:
>
>> On 10/11/2020 20:43, RobH wrote:
>>> pi@raspberrypi:~/Downloads $ sudo nano ledstest.py
>>>
> I'll repeat my previous question: WHY are you using SUDO?
Because I have always done since I started using a Pi.
>
> Develop using the default account, and only use SUDO when the system
> tells you that you don't have privileges to perform some action. (Okay --
> it seems Adafruits neopixel library does claim it needs to be run as root;
> likely due to the need to set up DMA, but editing the script sure doesn't
> need to be done using "sudo")
>
>
>>> import board
>>> import neopixel
>>> from time import sleep
>>>
>>> pixels = neopixel.NeoPixel(board.D18, 56, brightness =1)
>
> That's a pretty long Neopixel strip, if it has 56 pixels on it.
No, it isn't, that's a short one by comparison to the ones with either
144 or 300 leds
>
>>> pixels.fill((0, 0, 0))
>>> sleep(2)
>
> The above fill appears to be a do nothing as you don't issue a .show()
> {You are filling the pixel array with all-OFF, sleeping 2 seconds, and
> then...
>
>>> pixels.fill((0, 0, 255))
>>> pixels.show()
>
> ... filling the array with all-BLUE, then issuing a .show() command to send
> these to the Neopixel strip. You also do not have anything delaying the
> program after this .show().}
>
> The Neopixel library has a built-in clean-up method which sets
> everything back to OFF and .show() it when your "pixels" object is garbage
> collected, and that occurs immediately after your pixels.show() statement,
> since the program itself ends at that point.
>
> And to save some traffic...
>
>> File "ledstest.py", line 6, in
>> print.pixels.fill((0, 0, 0))
>> AttributeError: 'builtin_function_or_method' object has no attribute
>> 'pixels'
>
> Of course that fails. print() is a function which takes as argument the
> item to be printed.
>
> print(pixels.fill((0, 0, 0)))
>
> Note that if the .fill() call does not return any status, this will print
>
> None
>
> Try running in interactive mode (entering each line at the prompt, as
> shown here. NOTE: I don't have a Neopixel strip attached, I'd have to hook
> an oscilloscope to D18 to see if anything happens -- more than I want to
> try at this moment.
>
> =-=-=
> pi@rpi3bplus-1:~$ sudo python3
> Python 3.7.3 (default, Jul 25 2020, 13:03:44)
> [GCC 8.3.0] on linux
> Type "help", "copyright", "credits" or "license" for more information.
>>>> import board
>>>> import neopixel
>>>> import time
>>>>
>>>> pixels = neopixel.NeoPixel(board.D18, 56, brightness = 1)
>>>> pixels.fill((0, 0, 0))
>>>> time.sleep(2)
>>>> pixels.fill((0, 0, 255))
>>>> pixels.show()
>>>> time.sleep(2)
>>>> exit()
> pi@rpi3bplus-1:~$
> =-=-=
>
>
Alright, the script needs some editing or whatever, but it was something
I used to see if it would light the leds up without errors, which it did
initially.
Anyway as per my post lower down, the problem was the actual led strip
and nothing else. I tried a 144 leds strip and it worked fine.
Thanks
--- SoupGate-Win32 v1.05
* Origin: Agency HUB, Dunedin - New Zealand | FidoUsenet Gateway (3:770/3)
|