Python Forum
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
While loop question
#1
Hi,

I have developed a small standalone device using Pi 3 and Python.
Basically it's 5 buttons that activate a countdown timer for 5 different time lapses.
(Like you would use in interval training) Time shows on a 2x16 lcd.

As these buttons are used randomly, there are 5 separate 'if event_detect(...'
waiting in an ever spinning While loop, (One for each GPIO pin)
All this works (fine). A sixth button does a shutdown -h...

But i am wondering if there is a more elegant way of doing this, because very
soon i may need 10 event_detects...with 10 if statements.

What other coding method, if any, a part from this ever spinning while loop,
could there be to achieve this? Basically it's waiting for random input from any number of GPIO pins.

thx,
Paul
Reply


Messages In This Thread
While loop question - by DPaul - Dec-21-2017, 03:41 PM
RE: While loop question - by wavic - Dec-21-2017, 04:55 PM
RE: While loop question - by DPaul - Dec-22-2017, 07:35 AM
RE: While loop question - by wavic - Dec-22-2017, 07:53 AM
RE: While loop question - by DPaul - Dec-22-2017, 09:21 AM
RE: While loop question - by wavic - Dec-22-2017, 09:29 AM
RE: While loop question - by DPaul - Dec-22-2017, 09:35 AM
RE: While loop question - by nilamo - Dec-28-2017, 06:06 PM
RE: While loop question - by DPaul - Dec-29-2017, 08:03 AM
RE: While loop question - by nilamo - Dec-29-2017, 03:25 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
  A question about 'Event loop is closed' fc5igm 2 2,255 Oct-05-2021, 02:00 AM
Last Post: fc5igm
Exclamation question about input, while loop, then print jamie_01 5 2,711 Sep-30-2021, 12:46 PM
Last Post: Underscore
  for loop question KEYS 1 1,746 Oct-27-2020, 11:42 PM
Last Post: jefsummers
  Netmiko Loop question sc00ter 2 3,343 Oct-24-2020, 10:54 PM
Last Post: sc00ter
  while loop question KEYS 2 2,029 Sep-26-2020, 11:02 PM
Last Post: KEYS
  New to programming, loop question tomyan 1 1,662 Sep-25-2020, 04:32 PM
Last Post: Larz60+
  while loop question spalisetty06 2 1,866 Aug-13-2020, 04:18 PM
Last Post: buran
  question about for loop Than999 5 2,517 Jun-09-2020, 02:16 PM
Last Post: Emekadavid
  Question about for loop not creating an infinite loop. FWendeburg 1 2,132 Feb-03-2019, 08:45 PM
Last Post: ichabod801
  Loop Condition Question malonn 6 3,497 Aug-01-2018, 01:56 PM
Last Post: malonn

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020