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?
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.
>> 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:~$
=-=-=
--
Wulfraed Dennis Lee Bieber AF6VN
wlfraed@ix.netcom.com http://wlfraed.microdiversity.freeddns.org/
--- SoupGate-Win32 v1.05
* Origin: Agency HUB, Dunedin - New Zealand | FidoUsenet Gateway (3:770/3)
|