GPIO.setboard(GPIO.PCPCPLUS) GPIO.setmode(GPIO.BOARD) GPIO.setwarnings(False) # initialise variables delayTime = 0.5 # in seconds ser = Serial('/dev/ttyS3', 9600) ser.flushInput() ser.flushOutput() # Input pin for the digital signal will be picked here Digital_PIN = 22 GPIO.setup(Digital_PIN, GPIO.IN, pull_up_down=GPIO.PUD_OFF) ############################################################################################################# # ######## # main program loop # ######## # The program reads the current value of the input pin # and shows it at the terminal try: while True: val = ser.readline() if 'J7' in val: # Output at the terminal if GPIO.input(Digital_PIN) == False:
#!/usr/bin/env python import OPi.GPIO as GPIO import time GPIO.setmode(GPIO.BOARD) GPIO.setup(26, GPIO.OUT) def toggle_led(time_period): GPIO.output(26, GPIO.HIGH) time.sleep(time_period) GPIO.output(26, GPIO.LOW) time.sleep(time_period) def led_stable(): GPIO.output(26, GPIO.LOW) def led_off(): GPIO.output(26, GPIO.HIGH)
import os import OPi.GPIO as GPIO from time import sleep # this lets us have a time delay GPIO.setboard(GPIO.ZERO) # Orange Pi Zero board GPIO.setmode(GPIO.SOC) # set up SOC numbering button = GPIO.PA + 10 # button is on PA10 led_button = GPIO.PA + 14 GPIO.setup( button, GPIO.IN, pull_up_down=GPIO.PUD_DOWN) # set PA10 as an output (Status led of board) GPIO.setup(led_button, GPIO.OUT) try: GPIO.output(led_button, 1) while True: if GPIO.input(button): # if pin button == 1 GPIO.output(led_button, 0) print "Button is 1/HIGH/True" os.system( 'fswebcam -r 1280x720 --png 9 --no-banner --no-timestamp --no-shadow --no-info --no-underlay --no-overlay -D 1 -S 5 fswebcam.png' ) os.system('lp -o fit-to-page fswebcam.png') for x in range(0, 33): GPIO.output(led_button, 1) # set port/pin value to 1/HIGH/True sleep(0.1) GPIO.output(led_button, 0) # set port/pin value to 0/LOW/False sleep(0.1) GPIO.output(led_button, 1) # set port/pin value to 1/HIGH/True sleep(0.1)
#!/usr/bin/env python # -*- coding: utf8 -*- #import RPi.GPIO as GPIO import OPi.GPIO as GPIO import MFRC522 import signal import time continue_reading = True relay_port = 8 GPIO.setmode(GPIO.BOARD) GPIO.setup(relay_port, GPIO.OUT) GPIO.output(relay_port, GPIO.LOW) # Capture SIGINT for cleanup when the script is aborted def end_read(signal, frame): global continue_reading print "Ctrl+C captured, ending read." continue_reading = False GPIO.cleanup() # Hook the SIGINT signal.signal(signal.SIGINT, end_read) # Create an object of the class MFRC522 MIFAREReader = MFRC522.MFRC522()
import time import sys import OPi.GPIO as GPIO import orangepi.zeroplus2h5 BOARD = orangepi.zeroplus2h5.BOARD GPIO.setmode(BOARD) pin=int(sys.argv[1]) GPIO.setup(pin, GPIO.OUT) while True: GPIO.output(pin, GPIO.HIGH) time.sleep(1) GPIO.output(pin, GPIO.LOW) time.sleep(1)
#Needed modules will be imported and configured. import OPi.GPIO as GPIO GPIO.setboard(GPIO.PCPCPLUS) # Orange Pi PC board GPIO.setmode(GPIO.BOARD) #The output pin, which is connected with the buzzer, will be declared here. GPIO_PIN = 7 GPIO.setup(GPIO_PIN, GPIO.OUT) #The software-PWM module will be initialized - a frequency of 500Hz will be taken as default. Frequenz = 500 #In Hertz pwm = GPIO.PWM(GPIO_PIN, Frequenz) pwm.start(50) # The program will wait for the input of a new PWM-frequency from the user. # Until then, the buzzer will be used with the before inputted frequency (default 500Hz). try: while (True): print "----------------------------------------" print "Current frequency: %d" % Frequenz Frequenz = input("Please input a new frequency (50-5000):") pwm.ChangeFrequency(Frequenz) except KeyboardInterrupt: # here you put any code you want to run before the program # exits when you press CTRL+C print "An error or exception occurred!" except: # this catches ALL other exceptions including errors. # You won't get any error messages for debugging # so only use it once your code is working print "Other error or exception occurred!"
def enable_gpio(self): global GPIO if not self.config.gpio_path: logging.debug("Configuring GPIOs") import orangepi.one import OPi.GPIO as GPIO GPIO.setmode(orangepi.one.BOARD) GPIO.setwarnings(False) else: logging.debug("Configuring GPIOs at: " + self.config.gpio_path) import RPi.GPIO as GPIO GPIO.setmode(GPIO.BCM) # sort GPIOs self.runtime = type("Runtime", (object, ), {}) self.runtime.switch_channels = {} self.runtime.flip_channels = {} self.runtime.pir_channels = {} self.runtime.last_pir_state = {} self.runtime.ct_ios = {} self.runtime.temp_channels = {} self.runtime.temp_power_sm = {} for acq in self.config.acq_io: if acq.acType == "SW": logging.debug("Configuring Switch: " + str(acq.acObject)) GPIO.setup(acq.acObject, GPIO.IN, pull_up_down=GPIO.PUD_UP) self.runtime.switch_channels.update({acq.name : acq.acObject}) self.runtime.ct_ios.update({acq.name : confirmation_threshold(GPIO.input(acq.acObject),3)}) elif acq.acType == "SW_INV": logging.debug("Configuring invSwitch: " + str(acq.acObject)) GPIO.setup(acq.acObject, GPIO.IN, pull_up_down=GPIO.PUD_UP) self.runtime.flip_channels.update({acq.name : acq.acObject}) self.runtime.ct_ios.update({acq.name : confirmation_threshold(not GPIO.input(acq.acObject),3)}) elif acq.acType == "PIR": logging.debug("Configuring PIR Sensor: " + str(acq.acObject)) GPIO.setup(acq.acObject, GPIO.IN, pull_up_down=GPIO.PUD_UP) self.runtime.pir_channels.update({acq.name : acq.acObject}) self.runtime.ct_ios.update({acq.name : confirmation_threshold(GPIO.input(acq.acObject),3)}) self.runtime.last_pir_state.update({acq.name : 0}) elif acq.acType == "TEMP": logging.debug("Configuring Temperature Sensor: " + str(acq.acObject)) self.runtime.temp_channels.update({acq.name : acq.acObject}) self.runtime.temp_power_sm.update({acq.name : TempSensorPower(self.config.temp_max_restart)}) elif acq.acType == "TEMP_FAULT": try: self.runtime.temp_fault raise KeyError("Temperature sensor fault channel already allocated") except AttributeError: logging.debug("Configuring Temperature Power Fault: " + str(acq.acObject)) self.runtime.temp_fault = acq.acObject GPIO.setup(acq.acObject, GPIO.IN, pull_up_down=GPIO.PUD_UP) self.runtime.temp_fault_sm = confirmation_threshold(not GPIO.input(acq.acObject),3) elif acq.acType == "TEMP_EN": try: self.runtime.temp_en raise KeyError("Temperature sensor enable channel already allocated") except AttributeError: logging.debug("Configuring Temperature Power Enable: " + str(acq.acObject)) self.runtime.temp_en = acq.acObject GPIO.setup(acq.acObject, GPIO.OUT) self.runtime.temp_power_commanded = True self.runtime.temp_power_on = True self.runtime.temp_power_last = True else: raise KeyError('"' + acq.acType + '"' + " is not a valid acquisition type")
#!/usr/bin/env python # -*- coding: utf-8 -*- import OPi.GPIO as GPIO import random from time import sleep # this lets us have a time delay GPIO.setboard(GPIO.PCPCPLUS) GPIO.setmode(GPIO.BOARD) # The output pins will be declared, which are connected with the LEDs. LED_Red = 16 LED_Green = 18 # Set pins to output mode GPIO.setup(LED_Red, GPIO.OUT) GPIO.setup(LED_Green, GPIO.OUT) Freq = 100 #Hz # The specific colors will be initialized. RED = GPIO.PWM(LED_Red, Freq) GREEN = GPIO.PWM(LED_Green, Freq) RED.start(0) GREEN.start(0) # This function generate the actually color # You can change the color with the specific color variable. # After the configuration of the color is finished, you will time.sleep to # configure how long the specific will be displayed.
def init_control_pins(control_pins): GPIO.setup(control_pins, GPIO.OUT, initial=GPIO.LOW)
#!/usr/bin/env/python3 import OPi.GPIO as GPIO import time from threading import Thread GPIO.setmode(GPIO.BCM) GPIO.setup(9, GPIO.IN, pull_up_down=GPIO.PUD_DOWN) global count global counting counting = 0 def firstFunction(): global counter global ts global counting count = 1 counter = 0 ts = time.time() while True: if (count == 1): GPIO.wait_for_edge(27, GPIO.RISING) counting = 1 counter += 1 print("Pulse comming ! (%s)") % counter ts = time.time()
def main(): """Start the bot.""" global bot, oled, logo_img, FONT2, serial, SCREENS_DIR, mail_thread, work_thread, FONT2 # Проверяем есть ли папка для сохранения данных if not os.path.isdir(LIB_DIR): os.mkdir(LIB_DIR) if not os.path.exists(LOG_PATH): os.mkdir(LOG_PATH) logFormatter = logging.Formatter("%(asctime)s [%(threadName)-12.12s] [%(levelname)-5.5s] %(message)s") pkg_name = vars(sys.modules[__name__])['__package__'] if pkg_name is None: pkg_name = __name__ fileHandler = logging.FileHandler('{0}/{1}.log'.format(LOG_PATH, pkg_name)) fileHandler.setFormatter(logFormatter) logger.addHandler(fileHandler) consoleHandler = logging.StreamHandler(sys.stdout) consoleHandler.setFormatter(logFormatter) logger.addHandler(consoleHandler) logger.setLevel(logging.INFO) logger.info("Service started") #Проверяем можно ли писать в эту папку try: fd, name = tempfile.mkstemp(dir=LIB_DIR) except Exception as _e: logger.error("Storage is not writable") else: os.close(fd) os.remove(os.path.join(LIB_DIR, name)) SCREENS_DIR = os.path.join(LIB_DIR, SCREENS_DIR) if not os.path.isdir(SCREENS_DIR): os.mkdir(SCREENS_DIR) loadSettings() try: model = None board_json = '/etc/board.json' if os.path.isfile(board_json): with open(board_json) as json_file: board = json.load(json_file) if board['model'] is not None and board['model']['id'] is not None: _manuf, model = board['model']['id'].split(',', 2) GPIO.setwarnings(False) if model == 'orangepi-zero': import orangepi.zero # pylint: disable=unused-import, import-outside-toplevel GPIO.setmode(orangepi.zero.BOARD) else: import orangepi.zeroplus2 # pylint: disable=unused-import, import-outside-toplevel GPIO.setmode(orangepi.zeroplus2.BOARD) GPIO.setup(PIN_NUM, GPIO.OUT) GPIO.output(PIN_NUM, GPIO.LOW if INVERT_PIN else GPIO.HIGH) oled = ssd1306(port=0, address=0x3C) except Exception as e: logger.error("Unable to init Hardware %s", e) try: FONT2 = ImageFont.truetype(os.path.join(os.path.dirname(__file__), 'fonts/C&C Red Alert [INET].ttf'), 15) except Exception as e: logger.error("Unable to Load font: %s", e) logo_loaded = False logo_file = os.path.join(LIB_DIR, LOGO_FILE) if os.path.isfile(logo_file): logo_img = Image.open(logo_file) logo_img.convert("L") logger.info("QR Loaded") logo_loaded = True if not logo_loaded: generate_logo(logo_file) ImageDraw.Draw(screen).rectangle([(0, 0), screen.size], fill=0) screen.paste(logo_img, (0, 0)) try: oled.display(screen) except Exception: pass serial = getSerial() logger.info('My serial is : %s', serial) # Create the Updater and pass it your bot's token. # Make sure to set use_context=True to use the new context based callbacks # Post version 12 this will no longer be necessary updater = Updater(TOKEN, use_context=True, user_sig_handler=sig_handler) # Get the dispatcher to register handlers dp = updater.dispatcher # on different commands - answer in Telegram dp.add_handler(CommandHandler("start", start)) dp.add_handler(CommandHandler("help", help_command)) dp.add_handler(CommandHandler("state", bot_state)) dp.add_handler(CommandHandler("turnon", bot_turnon)) dp.add_handler(CommandHandler("turnoff", bot_turnoff)) dp.add_handler(CommandHandler("logs", bot_logs, pass_args=True)) dp.add_handler(CommandHandler("serial", bot_serial)) dp.add_handler(CommandHandler("screen", bot_screen)) dp.add_handler(CommandHandler("savers", bot_savers, pass_args=True, pass_job_queue=True, pass_chat_data=True)) dp.add_handler(CommandHandler("logo", bot_logo, pass_args=True, pass_job_queue=True, pass_chat_data=True)) dp.add_handler(CommandHandler("password", bot_password)) dp.add_handler(MessageHandler(Filters.document, document_handler)) # ...and the error handler dp.add_error_handler(error_handler) logger.info("Bot started") # Start the Bot updater.start_polling() bot = updater.bot mail_thread = threading.Thread(target=check_mail, name="check_mail") mail_thread.e = threading.Event() work_thread = threading.Thread(target=check_work, name="check_work") work_thread.e = threading.Event() loadWork() mail_thread.start() work_thread.start() while True: try: bot.send_message(CHANNEL_ID, _('Bot Started'), "Markdown", True) except Exception: time.sleep(10) continue else: break bot.send_message(CHANNEL_ID, _('My IP: {}').format(get_ip_address()), "Markdown", True) # Run the bot until you press Ctrl-C or the process receives SIGINT, # SIGTERM or SIGABRT. This should be used most of the time, since # start_polling() is non-blocking and will stop the bot gracefully. updater.idle() GPIO.cleanup()
import requests import simplejson as json import subprocess import OPi.GPIO as GPIO import time import subprocess from MainConfig import MainConfig from Constants import Constants # Pin Definitons: onPin = 16 pwrKey = 12 statusPin = 18 GPIO.setmode(GPIO.BOARD) GPIO.setup(onPin, GPIO.OUT) GPIO.setup(pwrKey, GPIO.OUT) GPIO.setup(statusPin, GPIO.IN) def resetModem(): GPIO.output( onPin, GPIO.LOW) # set the GSM ON/OFF pin to low to turn off the modem time.sleep(10) GPIO.output( onPin, GPIO.HIGH) # set the GSM ON/OFF pin to high to turn on the modem time.sleep(5) # Then Toggle the power key GPIO.output(pwrKey, GPIO.HIGH) GPIO.output(pwrKey, GPIO.LOW)
#!/usr/bin/env python # -*- coding: utf-8 -*- import OPi.GPIO as GPIO import time # this lets us have a time delay GPIO.setboard(GPIO.ZEROPLUS2H5) # Orange Pi PC board GPIO.setmode(GPIO.BOARD) # set up BOARD BCM numbering GPIO.setup(19, GPIO.OUT) # set BCM7 (pin 26) as an output (LED) GPIO.setup(21, GPIO.OUT) # set BCM7 (pin 26) as an output (LED) GPIO.setup(23, GPIO.OUT) # set BCM7 (pin 26) as an output (LED) GPIO.output(23, 1) GPIO.output(21, 1) GPIO.output(19, 1) try: print("Press CTRL+C to exit") # while True: SendPIN = 23 GPIO.output(SendPIN, 0) time.sleep(0.5) GPIO.output(SendPIN, 1) time.sleep(1) GPIO.output(SendPIN, 0) time.sleep(0.5) GPIO.output(SendPIN, 1) time.sleep(1)
def __init__(self, input_pins, output_pins, conf_pre, conf_post, keyboard_name, bouncetime=200, polarity=0, pressed_on_key_down=True, *args, **kwargs): logger.debug( "__init__(input_pins = %s, output_pins = %s, bouncetime = %s, polarity = %s)", input_pins, output_pins, bouncetime, polarity) self.keyboard_name = keyboard_name self._polarity = polarity self._InputPins = map(int, input_pins) self._OutputPins = map(int, output_pins) self._pressed_on_key_down = pressed_on_key_down OPiGPIO.setwarnings(False) section_name = conf_pre + 'keyboard' + conf_post if doorpi.DoorPi().config.get(section_name, 'mode', "BOARD").upper() != "BOARD": logger.warning('only mode BOARD is supported') OPiGPIO.setmode(OPiGPIO.BOARD) # No pull_up_down support on Orange PI zero try: OPiGPIO.setup(self._InputPins, OPiGPIO.IN) except TypeError: logger.warning( 'you use an old version of GPIO library - fallback to single-register of input pins' ) for input_pin in self._InputPins: OPiGPIO.setup(input_pin, OPiGPIO.IN) for input_pin in self._InputPins: OPiGPIO.add_event_detect(input_pin, OPiGPIO.BOTH, callback=self.event_detect, bouncetime=int(bouncetime)) self._register_EVENTS_for_pin(input_pin, __name__) # issue #133 try: OPiGPIO.setup(self._OutputPins, OPiGPIO.OUT) except TypeError: logger.warning( 'you use an old version of GPIO library - fallback to single-register of input pins' ) for output_pin in self._OutputPins: OPiGPIO.setup(output_pin, OPiGPIO.OUT) # use set_output to register status @ dict self._OutputStatus for output_pin in self._OutputPins: self.set_output(output_pin, 0, False) self.register_destroy_action()
#!/usr/bin/python3 address Python 3 environment # -*- coding: utf-8 -*- import OPi.GPIO as GPIO from time import sleep # this lets us have a time delay numgpio=23 # As defined on Rasperry Pi 40 pins Connector. OK for Orange PI PC2 H5 GPIO.setmode(GPIO.BCM) # set up BCM numbering GPIO.setup(numgpio, GPIO.OUT) # set BCM7 (pin 26) as an output (LED) try: print ("Square signal 50Hz on pin 16. Press CTRL+C to exit") while True: GPIO.output(numgpio, 1) # set port/pin value to 1/HIGH/True sleep(0.01) GPIO.output(numgpio, 0) # set port/pin value to 0/LOW/False sleep(0.01) except KeyboardInterrupt: GPIO.output(numgpio, 0) # set port/pin value to 0/LOW/False GPIO.cleanup() # Clean GPIO print ("Bye from F1ATB.")
from OPi.constants import * import OPi.GPIO as GPIO _DATA0PIN = 3 _DATA1PIN = 5 GPIO.setmode(GPIO.BOARD) GPIO.setup(_DATA0PIN, GPIO.IN, pull_up_down=PUD_UP) GPIO.setup(_DATA1PIN, GPIO.IN, pull_up_down=PUD_UP) cardnumber = 0 bit_count = 0 for x in range(0, 26): data0 = GPIO.input(_DATA0PIN) data1 = GPIO.input(_DATA1PIN) while ((data0 == 1) and (data1 == 1)): data0 = GPIO.input(_DATA0PIN) data1 = GPIO.input(_DATA1PIN) cardnumber = cardnumber << 1 if data1 == 1: cardnumber = cardnumber | 0x01 bit_count = bit_count + 1 while ((data0 == 0) or (data1 == 0)): print data0, data1 data0 = GPIO.input(_DATA0PIN) data1 = GPIO.input(_DATA1PIN) cardnumber = cardnumber >> 1 cardnumber = cardnumber & 0x00ffffff print cardnumber
def setup_output(port): """Set up a GPIO as output.""" from OPi import GPIO GPIO.setup(port, GPIO.OUT)
from lib.setup import rooms, settings if settings['Make'] == 'OrangePi': import OPi.GPIO as GPIO else: import RPi.GPIO as GPIO if settings['GPIOMode'] == 'BOARD': GPIO.setmode(GPIO.BOARD) else: GPIO.setmode(GPIO.BCM) GPIO.setwarnings(False) def initialState(active_value): if active_value == 0: return GPIO.HIGH else: return GPIO.LOW for room in rooms: for Appliance in room['Controls']: if Appliance['Type'] == 'GPIO': initial_state = initialState(Appliance['ActiveState']) GPIO.setup(Appliance['Pin'], GPIO.OUT, initial= initial_state)
def setup_input(port): """Set up a GPIO as input.""" from OPi import GPIO GPIO.setup(port, GPIO.IN)
def getPiRevision(): "Gets the version number of the Raspberry Pi board" #return GPIO.RPI_REVISION return GPIO.OPI_REVISION def cleanup(self): GPIO.cleanup() GPIO.setmode(GPIO.BOARD) GPIO.setwarnings(False) GPIO.cleanup() GPIO.setup(11, GPIO.IN, pull_up_down=GPIO.PUD_DOWN) GPIO.setup(12, GPIO.IN, pull_up_down=GPIO.PUD_DOWN) GPIO.setup(13, GPIO.IN, pull_up_down=GPIO.PUD_DOWN) #while GPIO.input(11) == GPIO.HIGH: # time.sleep(0.01) # wait 10 ms to give CPU chance to do other things while 1: print print GPIO.input(11) print GPIO.input(12) print GPIO.input(13) time.sleep(0.2) # wait 10 ms to give CPU chance to do other things print "finished"
heater(heat_op) elif (t > t_max): heat_op = 0 #Stop the heater heater(heat_op) else: heat_op = 2 #Nothing doing last_op = -1 counter = 0 log_data(t, p, h) #Let's start init_bme280() GPIO.cleanup() GPIO.setboard(GPIO.ZEROPLUS2H5) # Orange Pi PC board GPIO.setmode(GPIO.BOARD) # set up BOARD BCM numbering GPIO.setup(PowerPIN, GPIO.OUT) #Pin 19 - power up transmitter GPIO.setup(OnPIN, GPIO.OUT) #Pin 21 - set to LOW to enable heater GPIO.setup(OffPIN, GPIO.OUT) #Pin 23 - set to LOW to disable heater s = sched.scheduler(time.time, time.sleep) s.enter(1, 1, time_func, ()) s.run() while True: time.sleep(1) GPIO.cleanup()
def setup_input(port): """Set up a GPIO as input.""" _LOGGER.debug("Setting up GPIO pin %i as input", port) GPIO.setup(port, GPIO.IN)
def setup(self): self.logger.debug('Setting up the SUNXI mode') GPIO.setmode(GPIO.SUNXI) GPIO.setup(self.pin, GPIO.OUT, initial=False) GPIO.setwarnings(False) self.logger.info('Setup')
# -*- coding: utf-8 -*- # Based on blink_led.py example from https://github.com/Jeremie-C/OrangePi.GPIO import OPi.GPIO as GPIO from time import sleep # Set Orange Pi PC board GPIO.setboard(GPIO.PCPCPLUS) # Set BCM numbering GPIO.setmode(GPIO.BCM) # Set pins as an output GPIO.setup(8, GPIO.OUT) # BCM 8 (physical 24) GPIO.setup(7, GPIO.OUT) # BCM 7 (physical 26) GPIO.setup(1, GPIO.OUT) # BCM 1 (physical 28) try: print ("Press CTRL+C to exit") # 0 --- LOW/False # 1 --- HIGH/True while True: GPIO.output(8, 1) sleep(0.1) GPIO.output(8, 0) sleep(0.1)
import serial import time import os import sys from pyA20.gpio import gpio from pyA20.gpio import port import dht import datetime import subprocess import smtplib import OPi.GPIO as GPIO GPIO.setwarnings(False) GPIO.setmode(GPIO.BOARD) GPIO.setup(15, GPIO.IN) #Read output from PIR motion sensor GPIO.setup(26, GPIO.OUT) #Read output from PIR motion sensor GPIO.setup(22, GPIO.OUT) #Read output from PIR motion sensor PIN2 = port.PA6 gpio.init() port = serial.Serial("/dev/ttyS1", baudrate=9600, timeout=3.0) msg = """From: Smart Home <Smart Home> MIME-Version: 1.0 Content-type: text/html Subject: Smart Home <div style="color: #fff !important; background-color:#f44336 !important;"> <h3>Warning!</h3> <p>Temperature High</p> </div> """
def __init__(self, dev='/dev/spidev1.0', spd=1000000): spi.openSPI(device=dev,speed=spd) GPIO.setmode(GPIO.BOARD) GPIO.setup(22, GPIO.OUT) GPIO.output(self.NRSTPD, 1) self.MFRC522_Init()
#!/usr/bin/env python import time import OPi.GPIO as GPIO import serial GPIO.setmode(GPIO.BOARD) GPIO.setup(22, GPIO.OUT) GPIO.output(22, 1) # Turn on the LoRa Module time.sleep(5) # Wait for some time to turn it on #GPIO.setup(15, GPIO.OUT) #GPIO.output(8,1) # Put the LoRa module in config mode time.sleep(2) def setChannel(channel): ser = serial.Serial(port='/dev/ttyS3', baudrate=9600, parity=serial.PARITY_NONE, stopbits=serial.STOPBITS_ONE, bytesize=serial.EIGHTBITS, timeout=1) checkConfigCmd = "C1C1C1" if ser == None: return False ser.flushInput() time.sleep(0.1)
# coding: utf-8 #test import orangepi.one from OPi import GPIO # Orange Pi One physical board pin to GPIO pin GPIO.setmode(orangepi.one.BOARD) GPIO.setup(40, GPIO.IN, pull_up_down=GPIO.PUD_UP) while GPIO.input(40) == GPIO.LOW: time.sleep(0.01) # wait 10 ms to give CPU chance to do other things print("Hourra")
#! /usr/bin/env python import lcddriver import os import sys import subprocess import time import OPi.GPIO as GPIO GPIO.setwarnings(False) GPIO.setmode(GPIO.BOARD) GPIO.setup(23, GPIO.OUT) GPIO.setup(21, GPIO.OUT) GPIO.setup(19, GPIO.OUT) GPIO.setup(11, GPIO.IN, pull_up_down=GPIO.PUD_DOWN) GPIO.setup(15, GPIO.IN, pull_up_down=GPIO.PUD_DOWN) GPIO.setup(13, GPIO.IN, pull_up_down=GPIO.PUD_DOWN) # Variaveis de conexão path = "Z00209.JCL" ipHost = "192.86.32.153" portHost = "10443" user = "******" passwd = "fruit102" # Function to submit the job def jobSub(job): # Submit and get jobid jobid = subprocess.check_output('zowe zos-jobs submit data-set "' + path + '(' + job + ')" -H ' + ipHost + ' -P ' + portHost + ' -u ' + user + ' --pw ' + passwd + ' --ru false --rff jobid --rft string', shell=True).decode(sys.stdout.encoding).strip() text = "JOB ID: " + jobid lcd.lcd_display_string(text, 3)
import OPi.GPIO as GPIO import glob import time from time import sleep GPIO.setboard(GPIO.PCPCPLUS) GPIO.setmode(GPIO.BOARD) # here you can modify the break between the measurements sleeptime = 1 # the one-wire input pin will be declared and the integrated pullup-resistor will be enabled GPIO_PIN = 3 GPIO.setup(GPIO_PIN, GPIO.IN, pull_up_down=GPIO.PUD_UP) # After the enabling of the pullup-resistor you have to wait till the communication with the DS18B20 sensor has started print('wait for initialisation...') base_dir = '/sys/bus/w1/devices/' while True: try: device_folder = glob.glob(base_dir + '28*')[0] break except IndexError: sleep(0.5) continue device_file = device_folder + '/w1_slave' # The function to read currently measurement at the sensor will be defined.