Python RPi.GPIO.IN Examples
The following are 30
code examples of RPi.GPIO.IN().
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example.
You may also want to check out all available functions/classes of the module
RPi.GPIO
, or try the search function
.
Example #1
Source File: __init__.py From phat-beat with MIT License | 7 votes |
def setup(): global _is_setup if _is_setup: return True atexit.register(_exit) GPIO.setmode(GPIO.BCM) GPIO.setwarnings(False) GPIO.setup([DAT, CLK], GPIO.OUT) GPIO.setup(BUTTONS, GPIO.IN, pull_up_down=GPIO.PUD_UP) for button in BUTTONS: GPIO.add_event_detect(button, GPIO.FALLING, callback=_handle_button, bouncetime=200) _is_setup = True
Example #2
Source File: charlieplexing-6-on-3.py From 52-Weeks-of-Pi with MIT License | 7 votes |
def main(): try: while True: for led in LEDS: for idx, pin in enumerate(led): if pin == O: GPIO.setup(PINS[idx], GPIO.IN) else: GPIO.setup(PINS[idx], GPIO.OUT) GPIO.output(PINS[idx], pin) time.sleep(.1) except KeyboardInterrupt: pass finally: GPIO.cleanup()
Example #3
Source File: _button.py From ai-makers-kit with MIT License | 6 votes |
def __init__(self, channel, polarity=GPIO.FALLING, pull_up_down=GPIO.PUD_UP, debounce_time=0.08): if polarity not in [GPIO.FALLING, GPIO.RISING]: raise ValueError( 'polarity must be one of: GPIO.FALLING or GPIO.RISING') self.channel = int(channel) self.polarity = polarity self.expected_value = polarity == GPIO.RISING self.debounce_time = debounce_time GPIO.setwarnings(False) GPIO.setmode(GPIO.BOARD) GPIO.setup(channel, GPIO.IN, pull_up_down=pull_up_down) self.callback = None
Example #4
Source File: controller.py From ran-django-template with GNU General Public License v3.0 | 6 votes |
def readUltrasonicSensor(): GPIO.setup(TRIGGER_PIN, GPIO.OUT) GPIO.setup(SENSOR_PIN, GPIO.IN) GPIO.output(TRIGGER_PIN, GPIO.LOW) time.sleep(0.3) GPIO.output(TRIGGER_PIN, True) time.sleep(0.00001) GPIO.output(TRIGGER_PIN, False) while GPIO.input(SENSOR_PIN) == 0: signaloff = time.time() while GPIO.input(SENSOR_PIN) == 1: signalon = time.time() timepassed = signalon - signaloff distance = timepassed * 17000 if distance < threshold: return 1 else: return 0
Example #5
Source File: sakshat.py From SAKS-SDK with GNU General Public License v2.0 | 6 votes |
def saks_gpio_init(self): #print 'saks_gpio_init' GPIO.setwarnings(False) GPIO.cleanup() GPIO.setmode(GPIO.BCM) GPIO.setup(PINS.BUZZER, GPIO.OUT) GPIO.output(PINS.BUZZER, GPIO.HIGH) for p in [PINS.IC_TM1637_DI, PINS.IC_TM1637_CLK, PINS.IC_74HC595_DS, PINS.IC_74HC595_SHCP, PINS.IC_74HC595_STCP]: GPIO.setup(p, GPIO.OUT) GPIO.output(p, GPIO.LOW) for p in [PINS.BUZZER, PINS.TACT_RIGHT, PINS.TACT_LEFT, PINS.DIP_SWITCH_1, PINS.DIP_SWITCH_2]: GPIO.setup(p, GPIO.OUT) GPIO.output(p, GPIO.HIGH) for p in [PINS.TACT_RIGHT, PINS.TACT_LEFT, PINS.DIP_SWITCH_1, PINS.DIP_SWITCH_2]: GPIO.setup(p, GPIO.IN, pull_up_down = GPIO.PUD_UP)
Example #6
Source File: sakshat.py From SAKS-tutorials with GNU General Public License v2.0 | 6 votes |
def saks_gpio_init(self): #print 'saks_gpio_init' GPIO.setwarnings(False) GPIO.cleanup() GPIO.setmode(GPIO.BCM) GPIO.setup(PINS.BUZZER, GPIO.OUT) GPIO.output(PINS.BUZZER, GPIO.HIGH) for p in [PINS.IC_TM1637_DI, PINS.IC_TM1637_CLK, PINS.IC_74HC595_DS, PINS.IC_74HC595_SHCP, PINS.IC_74HC595_STCP]: GPIO.setup(p, GPIO.OUT) GPIO.output(p, GPIO.LOW) for p in [PINS.BUZZER, PINS.TACT_RIGHT, PINS.TACT_LEFT, PINS.DIP_SWITCH_1, PINS.DIP_SWITCH_2]: GPIO.setup(p, GPIO.OUT) GPIO.output(p, GPIO.HIGH) for p in [PINS.TACT_RIGHT, PINS.TACT_LEFT, PINS.DIP_SWITCH_1, PINS.DIP_SWITCH_2]: GPIO.setup(p, GPIO.IN, pull_up_down = GPIO.PUD_UP)
Example #7
Source File: sakshat.py From SAKS-tutorials with GNU General Public License v2.0 | 6 votes |
def saks_gpio_init(self): #print 'saks_gpio_init' GPIO.setwarnings(False) GPIO.cleanup() GPIO.setmode(GPIO.BCM) GPIO.setup(PINS.BUZZER, GPIO.OUT) GPIO.output(PINS.BUZZER, GPIO.HIGH) for p in [PINS.IC_TM1637_DI, PINS.IC_TM1637_CLK, PINS.IC_74HC595_DS, PINS.IC_74HC595_SHCP, PINS.IC_74HC595_STCP]: GPIO.setup(p, GPIO.OUT) GPIO.output(p, GPIO.LOW) for p in [PINS.BUZZER, PINS.TACT_RIGHT, PINS.TACT_LEFT, PINS.DIP_SWITCH_1, PINS.DIP_SWITCH_2]: GPIO.setup(p, GPIO.OUT) GPIO.output(p, GPIO.HIGH) for p in [PINS.TACT_RIGHT, PINS.TACT_LEFT, PINS.DIP_SWITCH_1, PINS.DIP_SWITCH_2]: GPIO.setup(p, GPIO.IN, pull_up_down = GPIO.PUD_UP)
Example #8
Source File: buzzer.py From rainbow-hat with MIT License | 6 votes |
def setup(): """Setup piezo buzzer.""" global _is_setup, pwm if _is_setup: return GPIO.setmode(GPIO.BCM) GPIO.setwarnings(False) GPIO.setup(BUZZER, GPIO.OUT) # Set up the PWM and then set the pin to input # to prevent the signal from being output. # Since starting/stopping PWM causes a segfault, # this is the only way to manage the buzzer. pwm = GPIO.PWM(BUZZER, 1) GPIO.setup(BUZZER, GPIO.IN) pwm.start(50) _is_setup = True
Example #9
Source File: _button.py From ai-makers-kit with MIT License | 6 votes |
def __init__(self, channel, polarity=GPIO.FALLING, pull_up_down=GPIO.PUD_UP, debounce_time=0.08): if polarity not in [GPIO.FALLING, GPIO.RISING]: raise ValueError( 'polarity must be one of: GPIO.FALLING or GPIO.RISING') self.channel = int(channel) self.polarity = polarity self.expected_value = polarity == GPIO.RISING self.debounce_time = debounce_time GPIO.setwarnings(False) GPIO.setmode(GPIO.BOARD) GPIO.setup(channel, GPIO.IN, pull_up_down=pull_up_down) self.callback = None
Example #10
Source File: sakshat.py From SAKS-tutorials with GNU General Public License v2.0 | 6 votes |
def saks_gpio_init(self): #print 'saks_gpio_init' GPIO.setwarnings(False) GPIO.cleanup() GPIO.setmode(GPIO.BCM) GPIO.setup(PINS.BUZZER, GPIO.OUT) GPIO.output(PINS.BUZZER, GPIO.HIGH) for p in [PINS.IC_TM1637_DI, PINS.IC_TM1637_CLK, PINS.IC_74HC595_DS, PINS.IC_74HC595_SHCP, PINS.IC_74HC595_STCP]: GPIO.setup(p, GPIO.OUT) GPIO.output(p, GPIO.LOW) for p in [PINS.BUZZER, PINS.TACT_RIGHT, PINS.TACT_LEFT, PINS.DIP_SWITCH_1, PINS.DIP_SWITCH_2]: GPIO.setup(p, GPIO.OUT) GPIO.output(p, GPIO.HIGH) for p in [PINS.TACT_RIGHT, PINS.TACT_LEFT, PINS.DIP_SWITCH_1, PINS.DIP_SWITCH_2]: GPIO.setup(p, GPIO.IN, pull_up_down = GPIO.PUD_UP)
Example #11
Source File: sakshat.py From SAKS-tutorials with GNU General Public License v2.0 | 6 votes |
def saks_gpio_init(self): #print 'saks_gpio_init' GPIO.setwarnings(False) GPIO.cleanup() GPIO.setmode(GPIO.BCM) GPIO.setup(PINS.BUZZER, GPIO.OUT) GPIO.output(PINS.BUZZER, GPIO.HIGH) for p in [PINS.IC_TM1637_DI, PINS.IC_TM1637_CLK, PINS.IC_74HC595_DS, PINS.IC_74HC595_SHCP, PINS.IC_74HC595_STCP]: GPIO.setup(p, GPIO.OUT) GPIO.output(p, GPIO.LOW) for p in [PINS.BUZZER, PINS.TACT_RIGHT, PINS.TACT_LEFT, PINS.DIP_SWITCH_1, PINS.DIP_SWITCH_2]: GPIO.setup(p, GPIO.OUT) GPIO.output(p, GPIO.HIGH) for p in [PINS.TACT_RIGHT, PINS.TACT_LEFT, PINS.DIP_SWITCH_1, PINS.DIP_SWITCH_2]: GPIO.setup(p, GPIO.IN, pull_up_down = GPIO.PUD_UP)
Example #12
Source File: sakshat.py From SAKS-tutorials with GNU General Public License v2.0 | 6 votes |
def saks_gpio_init(self): #print 'saks_gpio_init' GPIO.setwarnings(False) GPIO.cleanup() GPIO.setmode(GPIO.BCM) GPIO.setup(PINS.BUZZER, GPIO.OUT) GPIO.output(PINS.BUZZER, GPIO.HIGH) for p in [PINS.IC_TM1637_DI, PINS.IC_TM1637_CLK, PINS.IC_74HC595_DS, PINS.IC_74HC595_SHCP, PINS.IC_74HC595_STCP]: GPIO.setup(p, GPIO.OUT) GPIO.output(p, GPIO.LOW) for p in [PINS.BUZZER, PINS.TACT_RIGHT, PINS.TACT_LEFT, PINS.DIP_SWITCH_1, PINS.DIP_SWITCH_2]: GPIO.setup(p, GPIO.OUT) GPIO.output(p, GPIO.HIGH) for p in [PINS.TACT_RIGHT, PINS.TACT_LEFT, PINS.DIP_SWITCH_1, PINS.DIP_SWITCH_2]: GPIO.setup(p, GPIO.IN, pull_up_down = GPIO.PUD_UP)
Example #13
Source File: tm1637.py From raspberrypi-examples with MIT License | 6 votes |
def writeByte(self, data): for i in range(0, 8): IO.output(self.__Clkpin, IO.LOW) if(data & 0x01): IO.output(self.__Datapin, IO.HIGH) else: IO.output(self.__Datapin, IO.LOW) data = data >> 1 IO.output(self.__Clkpin, IO.HIGH) # wait for ACK IO.output(self.__Clkpin, IO.LOW) IO.output(self.__Datapin, IO.HIGH) IO.output(self.__Clkpin, IO.HIGH) IO.setup(self.__Datapin, IO.IN) while(IO.input(self.__Datapin)): sleep(0.001) if(IO.input(self.__Datapin)): IO.setup(self.__Datapin, IO.OUT) IO.output(self.__Datapin, IO.LOW) IO.setup(self.__Datapin, IO.IN) IO.setup(self.__Datapin, IO.OUT)
Example #14
Source File: sakshat.py From SAKS-tutorials with GNU General Public License v2.0 | 5 votes |
def saks_gpio_init(self): #print 'saks_gpio_init' GPIO.setwarnings(False) GPIO.cleanup() GPIO.setmode(GPIO.BCM) GPIO.setup(PINS.BUZZER, GPIO.OUT) GPIO.output(PINS.BUZZER, GPIO.HIGH) for p in [PINS.BUZZER, PINS.TACT_RIGHT, PINS.TACT_LEFT, PINS.DIP_SWITCH_1, PINS.DIP_SWITCH_2]: GPIO.setup(p, GPIO.OUT) GPIO.output(p, GPIO.HIGH) for p in PINS.LEDS + PINS.DIGITAL_DISPLAY + PINS.DIGITAL_DISPLAY_SELECT: GPIO.setup(p, GPIO.OUT) GPIO.output(p, GPIO.HIGH) for p in [PINS.TACT_RIGHT, PINS.TACT_LEFT, PINS.DIP_SWITCH_1, PINS.DIP_SWITCH_2]: GPIO.setup(p, GPIO.IN, pull_up_down = GPIO.PUD_UP) #GPIO.setup(p, GPIO.IN) #由于SAKS的蓝色LED和数码管共享引脚,此处将数码管位选关闭,只让信号作用于LED #GPIO.setup(17, GPIO.OUT, initial = GPIO.HIGH) #GPIO.setup(27, GPIO.OUT, initial = GPIO.HIGH) #GPIO.setup(22, GPIO.OUT, initial = GPIO.HIGH) #GPIO.setup(10, GPIO.OUT, initial = GPIO.HIGH)
Example #15
Source File: sakshat.py From SAKS-tutorials with GNU General Public License v2.0 | 5 votes |
def saks_gpio_init(self): #print 'saks_gpio_init' GPIO.setwarnings(False) GPIO.cleanup() GPIO.setmode(GPIO.BCM) GPIO.setup(PINS.BUZZER, GPIO.OUT) GPIO.output(PINS.BUZZER, GPIO.HIGH) for p in [PINS.BUZZER, PINS.TACT_RIGHT, PINS.TACT_LEFT, PINS.DIP_SWITCH_1, PINS.DIP_SWITCH_2]: GPIO.setup(p, GPIO.OUT) GPIO.output(p, GPIO.HIGH) for p in PINS.LEDS + PINS.DIGITAL_DISPLAY + PINS.DIGITAL_DISPLAY_SELECT: GPIO.setup(p, GPIO.OUT) GPIO.output(p, GPIO.HIGH) for p in [PINS.TACT_RIGHT, PINS.TACT_LEFT, PINS.DIP_SWITCH_1, PINS.DIP_SWITCH_2]: GPIO.setup(p, GPIO.IN, pull_up_down = GPIO.PUD_UP) #GPIO.setup(p, GPIO.IN) #由于SAKS的蓝色LED和数码管共享引脚,此处将数码管位选关闭,只让信号作用于LED #GPIO.setup(17, GPIO.OUT, initial = GPIO.HIGH) #GPIO.setup(27, GPIO.OUT, initial = GPIO.HIGH) #GPIO.setup(22, GPIO.OUT, initial = GPIO.HIGH) #GPIO.setup(10, GPIO.OUT, initial = GPIO.HIGH)
Example #16
Source File: sakshat.py From SAKS-tutorials with GNU General Public License v2.0 | 5 votes |
def saks_gpio_init(self): #print 'saks_gpio_init' GPIO.setwarnings(False) GPIO.cleanup() GPIO.setmode(GPIO.BCM) GPIO.setup(PINS.BUZZER, GPIO.OUT) GPIO.output(PINS.BUZZER, GPIO.HIGH) for p in [PINS.BUZZER, PINS.TACT_RIGHT, PINS.TACT_LEFT, PINS.DIP_SWITCH_1, PINS.DIP_SWITCH_2]: GPIO.setup(p, GPIO.OUT) GPIO.output(p, GPIO.HIGH) for p in PINS.LEDS + PINS.DIGITAL_DISPLAY + PINS.DIGITAL_DISPLAY_SELECT: GPIO.setup(p, GPIO.OUT) GPIO.output(p, GPIO.HIGH) for p in [PINS.TACT_RIGHT, PINS.TACT_LEFT, PINS.DIP_SWITCH_1, PINS.DIP_SWITCH_2]: GPIO.setup(p, GPIO.IN, pull_up_down = GPIO.PUD_UP) #GPIO.setup(p, GPIO.IN) #由于SAKS的蓝色LED和数码管共享引脚,此处将数码管位选关闭,只让信号作用于LED #GPIO.setup(17, GPIO.OUT, initial = GPIO.HIGH) #GPIO.setup(27, GPIO.OUT, initial = GPIO.HIGH) #GPIO.setup(22, GPIO.OUT, initial = GPIO.HIGH) #GPIO.setup(10, GPIO.OUT, initial = GPIO.HIGH)
Example #17
Source File: sakshat.py From SAKS-tutorials with GNU General Public License v2.0 | 5 votes |
def saks_gpio_init(self): #print 'saks_gpio_init' GPIO.setwarnings(False) GPIO.cleanup() GPIO.setmode(GPIO.BCM) GPIO.setup(PINS.BUZZER, GPIO.OUT) GPIO.output(PINS.BUZZER, GPIO.HIGH) for p in [PINS.BUZZER, PINS.TACT_RIGHT, PINS.TACT_LEFT, PINS.DIP_SWITCH_1, PINS.DIP_SWITCH_2]: GPIO.setup(p, GPIO.OUT) GPIO.output(p, GPIO.HIGH) for p in PINS.LEDS + PINS.DIGITAL_DISPLAY + PINS.DIGITAL_DISPLAY_SELECT: GPIO.setup(p, GPIO.OUT) GPIO.output(p, GPIO.HIGH) for p in [PINS.TACT_RIGHT, PINS.TACT_LEFT, PINS.DIP_SWITCH_1, PINS.DIP_SWITCH_2]: GPIO.setup(p, GPIO.IN, pull_up_down = GPIO.PUD_UP) #GPIO.setup(p, GPIO.IN) #由于SAKS的蓝色LED和数码管共享引脚,此处将数码管位选关闭,只让信号作用于LED #GPIO.setup(17, GPIO.OUT, initial = GPIO.HIGH) #GPIO.setup(27, GPIO.OUT, initial = GPIO.HIGH) #GPIO.setup(22, GPIO.OUT, initial = GPIO.HIGH) #GPIO.setup(10, GPIO.OUT, initial = GPIO.HIGH)
Example #18
Source File: CandleSimulation.py From 52-Weeks-of-Pi with MIT License | 5 votes |
def initialize_gpio(): GPIO.setmode(GPIO.BOARD) GPIO.setup([R,G], GPIO.OUT, initial=GPIO.LOW) GPIO.setup(BUTTON, GPIO.IN, pull_up_down=GPIO.PUD_DOWN) GPIO.add_event_detect(BUTTON, GPIO.FALLING, fan_the_flame, 250)
Example #19
Source File: assistant.py From voicetools with Apache License 2.0 | 5 votes |
def set_voice_sensor(): GPIO.setup(GPIOConfig.VOICE_SENSOR, GPIO.IN, pull_up_down=GPIO.PUD_UP) GPIO.add_event_detect(GPIOConfig.VOICE_SENSOR, GPIO.FALLING)
Example #20
Source File: rpi_gpio.py From pcaspy with BSD 3-Clause "New" or "Revised" License | 5 votes |
def __init__(self): super(myDriver, self).__init__() GPIO.setmode(GPIO.BOARD) GPIO.setup(PIN_INP, GPIO.IN) GPIO.setup(PIN_OUT, GPIO.OUT) GPIO.setup(PIN_PWM, GPIO.OUT) GPIO.add_event_detect(PIN_INP, GPIO.BOTH, callback=self.input_callback) self.pwm = GPIO.PWM(PIN_PWM, 1) # 1 Hz
Example #21
Source File: sensors.py From rl-rc-car with MIT License | 5 votes |
def __init__(self, in_p): self.in_p = in_p gpio.setup(self.in_p, gpio.IN) print("Initialized an IR proximity sensor at %d" % (self.in_p))
Example #22
Source File: sensors.py From rl-rc-car with MIT License | 5 votes |
def __init__(self, in_p, out_p, max_iterations=1000, num_readings=5, max_distance=90): self.in_p = in_p self.out_p = out_p gpio.setup(self.out_p, gpio.OUT) gpio.setup(self.in_p, gpio.IN) gpio.output(self.out_p, False) self.max_distance = max_distance self.num_readings = num_readings self.max_iterations = max_iterations print("Initializing a sonar sensor at %d (in) %d (out)" % (self.in_p, self.out_p)) time.sleep(2) print("Ready.")
Example #23
Source File: deskcycle_test.py From BlogCode with MIT License | 5 votes |
def __init__(self): print "setting up GPIO" GPIO.setmode(GPIO.BOARD) GPIO.setup(DeskCycle.PIN,GPIO.IN,pull_up_down=GPIO.PUD_UP) self.hitCount=0 pin2=38 GPIO.setup(pin2,GPIO.IN,pull_up_down=GPIO.PUD_DOWN) GPIO.add_event_detect(pin2, GPIO.FALLING, callback=self.pin_2_event,bouncetime=100)
Example #24
Source File: deskcycle_btkclient.py From BlogCode with MIT License | 5 votes |
def __init__(self): #the structure for a bt keyboard input report (size is 10 bytes) self.state=[ 0xA1, #this is an input report 0x01, #Usage report = Keyboard #Bit array for Modifier keys [0, #Right GUI - Windows Key 0, #Right ALT 0, #Right Shift 0, #Right Control 0, #Left GUI 0, #Left ALT 0, #Left Shift 0], #Left Control 0x00, #Vendor reserved 0x00, #rest is space for 6 keys 0x00, 0x00, 0x00, 0x00, 0x00] print "setting up GPIO" GPIO.setmode(GPIO.BOARD) GPIO.setup(DeskCycle.PIN,GPIO.IN,pull_up_down=GPIO.PUD_UP) print "setting up DBus Client" self.bus = dbus.SystemBus() self.btkservice = self.bus.get_object('org.yaptb.btkbservice','/org/yaptb/btkbservice') self.iface = dbus.Interface(self.btkservice,'org.yaptb.btkbservice') #hard code the key to send self.state[4]=DeskCycle.KEYCODE
Example #25
Source File: hx711.py From pydPiper with MIT License | 5 votes |
def __init__(self, dout, pd_sck, gain=128): self.PD_SCK = pd_sck self.DOUT = dout GPIO.setmode(GPIO.BCM) GPIO.setup(self.PD_SCK, GPIO.OUT) GPIO.setup(self.DOUT, GPIO.IN) self.GAIN = 0 self.REFERENCE_UNIT = 1 # The value returned by the hx711 that corresponds to your reference unit AFTER dividing by the SCALE. self.OFFSET = 1 self.lastVal = long(0) self.LSByte = [2, -1, -1] self.MSByte = [0, 3, 1] self.MSBit = [0, 8, 1] self.LSBit = [7, -1, -1] self.byte_range_values = self.LSByte self.bit_range_values = self.MSBit self.set_gain(gain) time.sleep(1)
Example #26
Source File: __init__.py From automation-hat with MIT License | 5 votes |
def setup(self): if self._is_setup: return False setup() GPIO.setup(self.pin, GPIO.IN) self._is_setup = True
Example #27
Source File: spi_clk_off.py From hometop_HT3 with GNU General Public License v3.0 | 5 votes |
def setup_gpio(): GPIO.setwarnings(False) GPIO.setmode(GPIO.BCM) # setup Header Pin23 for input GPIO.setup (11, GPIO.IN)
Example #28
Source File: circo.py From circo with MIT License | 5 votes |
def __init__(self, swmac, gwmac, ip, iface, wiface, dns, prx): threading.Thread.__init__(self) self.stoprequest = threading.Event() self.switchmac = swmac self.gwmac = gwmac self.ip = ip self.iface = iface self.wiface = wiface self.dns_srv = dns self.prxlist = prx GPIO.setmode(GPIO.BOARD) GPIO.setup(10, GPIO.IN, pull_up_down=GPIO.PUD_DOWN)
Example #29
Source File: wlt_2_watchdog.py From WLANThermo_v2 with GNU General Public License v3.0 | 5 votes |
def halt_v3_pi(): logger.info(_(u'Shutting down the Raspberry, Power Off (v3)')) # Stoppe die Dienste handle_service('WLANThermo', 'stop') handle_service('WLANThermoPIT', 'stop') # Schreibe aufs LCD tmp_filename = get_random_filename('/var/www/tmp/display/wd') while True: try: fw = open(tmp_filename, 'w') fw.write(_(u'---- ATTENTION! ----;---- WLANThermo ----;is now shutting down;Bye-bye!')) fw.flush() os.fsync(fw.fileno()) fw.close() os.rename(tmp_filename, '/var/www/tmp/display/wd') except IndexError: time.sleep(1) continue break # Sende Abschaltkommando an den ATtiny GPIO.setup(27, GPIO.OUT) GPIO.output(27,True) time.sleep(1) GPIO.output(27,False) time.sleep(1) GPIO.setup(27, GPIO.IN, pull_up_down=GPIO.PUD_DOWN) # Fahre Betriebssystem herunter bashCommand = 'sudo poweroff' retcode = subprocess.Popen(bashCommand.split()) retcode.wait() if retcode < 0: logger.info(_(u'Terminated by signal')) else: logger.info(_(u'Child returned: ') + str(retcode))
Example #30
Source File: sensor.py From thingflow-python with Apache License 2.0 | 5 votes |
def __init__(self,sensor_id): """sensor_id is port number """ super().__init__() self.sensor_id = sensor_id GPIO.setmode(GPIO.BOARD) GPIO.setup(sensor_id,GPIO.IN)