diabeg
Posts: 34
Joined: Sat Nov 14, 2015 7:35 pm

Re: sense hat

Wed Feb 10, 2016 4:17 pm


diabeg
Posts: 34
Joined: Sat Nov 14, 2015 7:35 pm

Re: sense hat

Wed Feb 10, 2016 4:20 pm

Python 3.2.3 (default, Mar 1 2013, 11:53:50)
[GCC 4.6.3] on linux2
Type "copyright", "credits" or "license()" for more information.
>>>

DirkS
Posts: 10347
Joined: Tue Jun 19, 2012 9:46 pm
Location: Essex, UK

Re: sense hat

Wed Feb 10, 2016 4:25 pm

I would like to see the contents of the file window.
If you followed the worksheet then that has the code you entered (probably starting with 'from sense_hat')

diabeg
Posts: 34
Joined: Sat Nov 14, 2015 7:35 pm

Re: sense hat

Wed Feb 10, 2016 4:29 pm

Traceback (most recent call last):
File "/home/pi/sparkles.py", line 1, in <module>
from sense_hat import SenseHat
File "/usr/lib/python3/dist-packages/sense_hat/__init__.py", line 2, in <module>
from .sense_hat import SenseHat, SenseHat as AstroPi
File "/usr/lib/python3/dist-packages/sense_hat/sense_hat.py", line 14, in <module>
from PIL import Image # pillow
ImportError: No module named PIL
>>>

DirkS
Posts: 10347
Joined: Tue Jun 19, 2012 9:46 pm
Location: Essex, UK

Re: sense hat

Wed Feb 10, 2016 6:27 pm

Sorry, that traceback doesn't make any sense to me...

Can you post the contents of sparkles.py

diabeg
Posts: 34
Joined: Sat Nov 14, 2015 7:35 pm

Re: sense hat

Thu Feb 11, 2016 10:07 am

DirkS wrote:Sorry, that traceback doesn't make any sense to me...

Can you post the contents of sparkles.py

from sense_hat import SenseHat
sense = SenseHat





x = 4
y = 5
r = 19
g = 180
b = 230

sense.set_pixel (x, y, r, g, b)

DirkS
Posts: 10347
Joined: Tue Jun 19, 2012 9:46 pm
Location: Essex, UK

Re: sense hat

Thu Feb 11, 2016 12:49 pm

That looks OK.

Did you try to run any of the example scripts?
If so, di you have any problems?

if not, can you try the following:
Open a terminal window (LXTerminal and run the following (it's a long command, so I hope you can copy and paste)

Code: Select all

python3 /usr/src/sense-hat/examples/python-sense-hat/rotation.py
Please post any error messages.

ShiftPlusOne
Raspberry Pi Engineer & Forum Moderator
Raspberry Pi Engineer & Forum Moderator
Posts: 6228
Joined: Fri Jul 29, 2011 5:36 pm
Location: The unfashionable end of the western spiral arm of the Galaxy

Re: sense hat

Thu Feb 11, 2016 1:05 pm

Looks like it's and old wheezy image and pillow needs to be installed.

Code: Select all

sudo apt-get install libjpeg-dev python3-pip
sudo pip-3.2 install pillow

DirkS
Posts: 10347
Joined: Tue Jun 19, 2012 9:46 pm
Location: Essex, UK

Re: sense hat

Thu Feb 11, 2016 1:29 pm

ShiftPlusOne wrote:Looks like it's and old wheezy image and pillow needs to be installed.

Code: Select all

sudo apt-get install libjpeg-dev python3-pip
sudo pip-3.2 install pillow
That has already been dealt with...
See viewtopic.php?f=104&t=135426#p903142 for the current issue.
Can't see why that happens, that's why I want to make sure the example code runs without problems

diabeg
Posts: 34
Joined: Sat Nov 14, 2015 7:35 pm

Re: sense hat

Thu Feb 11, 2016 2:09 pm

DirkS wrote:That looks OK.

Did you try to run any of the example scripts?
If so, di you have any problems?

if not, can you try the following:
Open a terminal window (LXTerminal and run the following (it's a long command, so I hope you can copy and paste)

Code: Select all

python3 /usr/src/sense-hat/examples/python-sense-hat/rotation.py
Please post any error messages.
I copied and pasted ,clicked enter ,nothing happened on LXTerminal

But Sense Hat lit up in all its glorious colours
Is this a step forward?

DirkS
Posts: 10347
Joined: Tue Jun 19, 2012 9:46 pm
Location: Essex, UK

Re: sense hat

Thu Feb 11, 2016 2:29 pm

diabeg wrote:But Sense Hat lit up in all its glorious colours
Is this a step forward?
Yes. The hat is working *and* it also calls the same function (set_pixel) and apparently that works fine.

I just noticed one difference between your code and the worksheet:
Line 2 should be

Code: Select all

sense = SenseHat()
(note the parentheses).
Fix that and try again.

ShiftPlusOne
Raspberry Pi Engineer & Forum Moderator
Raspberry Pi Engineer & Forum Moderator
Posts: 6228
Joined: Fri Jul 29, 2011 5:36 pm
Location: The unfashionable end of the western spiral arm of the Galaxy

Re: sense hat

Thu Feb 11, 2016 2:48 pm

DirkS wrote:
ShiftPlusOne wrote:Looks like it's and old wheezy image and pillow needs to be installed.

Code: Select all

sudo apt-get install libjpeg-dev python3-pip
sudo pip-3.2 install pillow
That has already been dealt with...
See viewtopic.php?f=104&t=135426#p903142 for the current issue.
Can't see why that happens, that's why I want to make sure the example code runs without problems
Yes, but the latest error pasted says that it hasn't really been dealt with. It seems like at first it was lack of pillow, then that was solved and it was an error in code, then pillow again. But yeah, it does sound like things are sorted now.

diabeg
Posts: 34
Joined: Sat Nov 14, 2015 7:35 pm

Re: sense hat

Thu Feb 11, 2016 3:00 pm

DirkS wrote:
diabeg wrote:But Sense Hat lit up in all its glorious colours
Is this a step forward?
Yes. The hat is working *and* it also calls the same function (set_pixel) and apparently that works fine.

I just noticed one difference between your code and the worksheet:
Line 2 should be

Code: Select all

sense = SenseHat()
(note the parentheses).
Fix that and try again.
from sense_hat import SenseHat
sense = SenseHat()
x = 4
y = 5
r = 19
g = 180
b = 230
set_sense
sense.set_pixel(x, y, r, g, b )

Traceback (most recent call last):
File "/home/pi/sparkles'py 2.py", line 8, in <module>
set_sense
NameError: name 'set_sense' is not defined
>>>

DirkS
Posts: 10347
Joined: Tue Jun 19, 2012 9:46 pm
Location: Essex, UK

Re: sense hat

Thu Feb 11, 2016 3:04 pm

You put in a bit too much code.
Remove the line before last

Code: Select all

set_sense

diabeg
Posts: 34
Joined: Sat Nov 14, 2015 7:35 pm

Re: sense hat

Thu Feb 11, 2016 3:20 pm

DirkS wrote:You put in a bit too much code.
Remove the line before last

Code: Select all

set_sense

from sense_hat import SenseHat
sense = SenseHat()
x = 4
y = 5
r = 19
g = 180
b = 230
sense.set_pixel(x, y, r, g, b)

No change to the Hat lights but get this message

Python 3.2.3 (default, Mar 1 2013, 11:53:50)
[GCC 4.6.3] on linux2
Type "copyright", "credits" or "license()" for more information.
>>> ================================ RESTART ================================
>>>
>>> ================================ RESTART ================================
>>>
>>>

diabeg
Posts: 34
Joined: Sat Nov 14, 2015 7:35 pm

Re: sense hat

Thu Feb 11, 2016 3:30 pm

The Hat shows
l/h top red
r/h top blue
l/h btm green
r/h btm purple
Centre in Red question mark

DirkS
Posts: 10347
Joined: Tue Jun 19, 2012 9:46 pm
Location: Essex, UK

Re: sense hat

Thu Feb 11, 2016 3:37 pm

diabeg wrote:The Hat shows
l/h top red
r/h top blue
l/h btm green
r/h btm purple
Centre in Red question mark
Aha, I think that's the result of the example code I let you run.
It could be that this is masking the changes you made to the screen contents
Try adding the line

Code: Select all

sense.clear()
just after the line 'sense=SenseHat()'
This should switch off all the LEDs

Code: Select all

from sense_hat import SenseHat
sense = SenseHat()
sense.clear()

x = 4
y = 5
r = 19
g = 180
b = 230
sense.set_pixel(x, y, r, g, b)

diabeg
Posts: 34
Joined: Sat Nov 14, 2015 7:35 pm

Re: sense hat

Thu Feb 11, 2016 4:03 pm

the lights have switched off except a blue light just off centre which remains on

I have tried again as below

from sense_hat import SenseHat
sense = SenseHat()
x = 4
y = 5
r = 19
g = 180
b = 230
sense.set_pixel(x, y, r, g, b)

and get this message

Python 3.2.3 (default, Mar 1 2013, 11:53:50)
[GCC 4.6.3] on linux2
Type "copyright", "credits" or "license()" for more information.
>>> ================================ RESTART ================================
>>>
>>> ================================ RESTART ================================
>>>
>>>

DirkS
Posts: 10347
Joined: Tue Jun 19, 2012 9:46 pm
Location: Essex, UK

Re: sense hat

Thu Feb 11, 2016 4:18 pm

[quote="diabeg"]the lights have switched off except a blue light just off centre which remains on
That means it's working. Blue (b) is full on, with some green.
You can try other colours by changing the values for red, blue and green. 0 is off, 255 is full on.

And of course you can now carry on with the rest of the worksheet :D

diabeg
Posts: 34
Joined: Sat Nov 14, 2015 7:35 pm

Re: sense hat

Thu Feb 11, 2016 4:32 pm

DirkS wrote:
diabeg wrote:the lights have switched off except a blue light just off centre which remains on
That means it's working. Blue (b) is full on, with some green.
You can try other colours by changing the values for red, blue and green. 0 is off, 255 is full on.

And of course you can now carry on with the rest of the worksheet :D
Hello DirkS
I have been very grateful to you over the last few days
I will explain a little about me
I am in my mid 80s and I an self taught on computers
My family wanted to give me a surprise for Christmas
The choice was left to our eldest grandson
He chose Raspberry Pi and Sense hat
Half the family did not know what it was
The local library thought I had requested a cookery book
Although as you know I am slow and make mistakes it has been pure joy
Hopefully when I am more confident I too will be able to contribute to this forum
Sincerely
Thank you
Diabeg :)

DirkS
Posts: 10347
Joined: Tue Jun 19, 2012 9:46 pm
Location: Essex, UK

Re: sense hat

Thu Feb 11, 2016 4:54 pm

My pleasure!
I have learned a few things about Python while trying to help you.

And I'm glad you stuck with it.
I'm sure you'll have more fun with the Pi in the future (and some more frustrating moments ;) )

Return to “Astro Pi”