Woll
Posts: 472
Joined: Mon Jul 06, 2015 2:14 am
Location: Cloud Cuckoo Land

Adding a timer to Sense Hat

Sat Oct 10, 2015 12:01 am

I've brought a Sense Hat, which I'm really impressed with.
I'm coping code from a RPF tutorial and I'm trying to add a timer to it which I've modified from a pygame tutorial from Magpi 2.
The only problem is, it doesn't seem to work.
Has anyone got any ideas about where I'm going wrong?

Code: Select all

from sense_hat import SenseHat
clock = SenseHat.time.Clock()
sense = SenseHat()

# Full Red
sense.clear(255,0,0)
SenseHat.display.update();SenceHat.time.wait(2000)

# Full Green
sense.clear(0,255,0)
SenseHat.display.update();SenceHat.time.wait(2000)

# Full Blue
sense.clear(0,0,255)
SenseHat.display.update();SenceHat.time.wait(2000)
Who ate all the Pi's? Who ate all the Pi's?
Boris Johnson, Boris Johnson,
Who ate all the Pi's?

LeoWhite
Posts: 131
Joined: Mon Apr 08, 2013 9:20 am
Contact: Website

Re: Adding a timer to Sense Hat

Sat Oct 10, 2015 2:22 pm

Hi,
Woll wrote:I've brought a Sense Hat, which I'm really impressed with.
I'm coping code from a RPF tutorial and I'm trying to add a timer to it which I've modified from a pygame tutorial from Magpi 2.
The only problem is, it doesn't seem to work.
Has anyone got any ideas about where I'm going wrong?
Shouldn't

Code: Select all

SenceHat.time.wait(2000)
be

Code: Select all

SenseHat.time.wait(2000)
In my own python scripts I've tended to use the 'time.sleep' call to add a delay in the code. e.g.

Code: Select all

import time

time.sleep(1)
time.sleep(0.001)


Leo

Woll
Posts: 472
Joined: Mon Jul 06, 2015 2:14 am
Location: Cloud Cuckoo Land

Re: Adding a timer to Sense Hat

Sat Oct 10, 2015 4:31 pm

Thanks alot for your reply. I tend to spell commands wrong quit a bit. I'm still at the basics. :|
Who ate all the Pi's? Who ate all the Pi's?
Boris Johnson, Boris Johnson,
Who ate all the Pi's?

LeoWhite
Posts: 131
Joined: Mon Apr 08, 2013 9:20 am
Contact: Website

Re: Adding a timer to Sense Hat

Sat Oct 10, 2015 6:51 pm

Woll wrote:Thanks alot for your reply. I tend to spell commands wrong quit a bit. I'm still at the basics. :|
Everybody spells things wrong! Although mine usually get reported by the compiler!

Have fun playing around with the Sense HAT!

Leo

Return to “Astro Pi”