Python Forum
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
first steps with python3
#4
(Jul-03-2017, 12:19 PM)Larz60+ Wrote: what does the miflora code look like?

The second module can be written like:
import RPi.GPIO as GPIO


class Gpio:
    def __init__(self):
        GPIO.setmode(GPIO.BCM)  # set board mode to Broadcom

    def gpio_setup(self, pins):
        for pin in pins:
            GPIO.setup(pin, GPIO.OUT)

    def gpio_out(selfself, pins):
        for pin in pins:
            GPIO.output(pin, 1)

def main(self):
    gpio = Gpio()
    setup_seq = [27, 22, 23, 24, 25]
    output_seq = [17, 27, 22, 23, 24, 25]
    gpio.gpio_setup(setup_seq)
    gpio.gpio_out(output_seq)

if __name__ == '__main__':
    main()

thanks for that, I have modded the main script to reflect the suggestions, much neater..
def main(self):
    gpio = Gpio()
    iopin_seq = [17, 27, 22, 23, 24, 25]
    btooth_seq = ["C4:7C:8D:64:43:6F","C4:7C:8D:64:43:C8","C4:7C:8D:64:43:61","C4:7C:8D:64:47:A7","C4:7C:8D:64:43:AE","C4:7C:8D:64:43:F5"]
    plant_id = 1
    gpio.gpio_setup(iopin_seq)
    gpio.gpio_out(iopin_seq)
    for bt in btooth_seq:
        myfunc1.sensortest(plant_id, bt ,iopin_seq[plant_id-1])
        plant_id = plant_id + 1 
    GPIO.cleanup()
                
if __name__ == '__main__':
    main('self')
Reply


Messages In This Thread
first steps with python3 - by hunnimonstr - Jul-03-2017, 11:27 AM
RE: first steps with python3 - by Larz60+ - Jul-03-2017, 12:19 PM
RE: first steps with python3 - by hunnimonstr - Jul-03-2017, 02:24 PM
RE: first steps with python3 - by hunnimonstr - Jul-03-2017, 01:08 PM
RE: first steps with python3 - by nilamo - Jul-03-2017, 03:05 PM
RE: first steps with python3 - by hunnimonstr - Jul-03-2017, 08:49 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
Thumbs Up Sorting Steps MoreMoney 19 1,403 Mar-31-2024, 10:59 AM
Last Post: Pedroski55
  Next steps for using API data Rebster 6 2,767 Oct-10-2020, 05:35 PM
Last Post: perfringo
  Keep Toggle View through Slider Steps yourboyjoe 1 1,777 Aug-10-2020, 07:32 PM
Last Post: Yoriz
  Files to store configuration and steps for a industrial process control application Danieru 1 1,888 Aug-03-2020, 05:43 PM
Last Post: buran
  Gnuradio python3 is not compatible python3 xmlrpc library How Can I Fix İt ? muratoznnnn 3 5,119 Nov-07-2019, 05:47 PM
Last Post: DeaD_EyE
  Pexpect baby steps slouw 9 8,274 May-23-2019, 10:21 AM
Last Post: heiner55

Forum Jump:

User Panel Messages

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