Go to advanced search

by jamesrussell
Sat Dec 21, 2013 10:02 pm
Forum: Python
Topic: Python Christmas Lights
Replies: 11
Views: 3453

Re: Python Christmas Lights

Untested, but this is what I had in mind: def alert(): global sequence sequence += 1 if (sequence > 3): sequence = 1 GPIO.add_event_detect(16, GPIO.RISING, callback=alert, bouncetime=150) Thank You!!!!! So much. Works perfectly! Lots of stupid lights flashing now. Happy Christmas/Holidays/Festivus ...
by jamesrussell
Sat Dec 21, 2013 7:14 pm
Forum: Python
Topic: Python Christmas Lights
Replies: 11
Views: 3453

Re: Python Christmas Lights

Simplest would be to just let a sequence run out before changing to the next sequence: while True: if (sequence == 1): setone() if (sequence == 2): settwo() if (sequence == 3): setthree() If you really need it to stop mid-sequence, it quickly gets messier Mid sequence stopping is a nice to have, ce...
by jamesrussell
Sat Dec 21, 2013 6:58 pm
Forum: Python
Topic: Python Christmas Lights
Replies: 11
Views: 3453

Re: Python Christmas Lights

Douglas6 wrote:You didn't hear it from me, but I'd simply make sequence a global variable. And then read up on why global variables are evil.
Lol, i'd already started along that line!
by jamesrussell
Sat Dec 21, 2013 6:45 pm
Forum: Python
Topic: Python Christmas Lights
Replies: 11
Views: 3453

Re: Python Christmas Lights

Simplest would be to just let a sequence run out before changing to the next sequence: while True: if (sequence == 1): setone() if (sequence == 2): settwo() if (sequence == 3): setthree() If you really need it to stop mid-sequence, it quickly gets messier Mid sequence stopping is a nice to have, ce...
by jamesrussell
Sat Dec 21, 2013 5:57 pm
Forum: Python
Topic: Python Christmas Lights
Replies: 11
Views: 3453

Re: Python Christmas Lights

My Python is sketchy at best, but two things, I think. One, the button rising edge interrupt is already running in it's own thread provided by RPi.GPIO (or is using real interrupts, same effect) Two, you could just as well run the light sequence in the main thread. It will be interrupted when the b...
by jamesrussell
Sat Dec 21, 2013 5:19 pm
Forum: Python
Topic: Python Christmas Lights
Replies: 11
Views: 3453

Re: Python Christmas Lights

davef21370 wrote:Why have the button in a thread, just put it in an infinite loop and have it control the light thread.

Dave.
That sounds good to me, I guess the button can just be in main. I am just not sure how to control the lights thread to change the sequence, any ideas?
by jamesrussell
Sat Dec 21, 2013 3:43 pm
Forum: Python
Topic: Python Christmas Lights
Replies: 11
Views: 3453

Python Christmas Lights

Hi All, I am looking for some help with my Christmas lights project. I have decided to start playing with Python and GPIO and thought as it's christmas it would be an interesting learning experience. So far I have got a working circuit and can flash two sets of LED christmas lights using sequences I...

Go to advanced search