Jul-03-2017, 02:24 PM
(This post was last modified: Jul-03-2017, 02:27 PM by hunnimonstr.)
(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')