Python RPi.GPIO.output() Examples
The following are 30
code examples of RPi.GPIO.output().
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: ic_tm1637.py From SAKS-SDK with GNU General Public License v2.0 | 6 votes |
def set_byte(self, data): ''' Set a byte :param data: data :return: void ''' for i in range (0, 8): self.set_bit((data >> i) & 0x01) GPIO.output(self.__pins['clk'], not self.__real_true) self.bus_delay() GPIO.output(self.__pins['di'], self.__real_true) self.bus_delay() GPIO.output(self.__pins['clk'], self.__real_true) self.bus_delay()
Example #2
Source File: ultrasonic-distance.py From raspberrypi-examples with MIT License | 6 votes |
def getValue(): GPIO.output(ptrig, 0) time.sleep(0.1) GPIO.output(ptrig, 1) time.sleep(0.00001) GPIO.output(ptrig, 0) while(0 == GPIO.input(pecho)): start = time.time() while(1 == GPIO.input(pecho)): end = time.time() delay = (end - start) * 1000 * 1000 time.sleep(0.1) distance = (delay / 58.0) if 2 < distance < 400: # working interval print("distance: %0.1f cm" % distance)
Example #3
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 #4
Source File: buzzer.py From SecPi with GNU General Public License v3.0 | 6 votes |
def buzz(self, duration): logging.debug("Buzzer: Trying to make some noise") start_time = time.time() state = True while (time.time() - start_time) < duration: GPIO.output(self.gpio_pin, state) if state: state = False time.sleep(0.5) else: state = True time.sleep(0.05) state = False GPIO.output(self.gpio_pin, state) logging.debug("Buzzer: Finished making noise")
Example #5
Source File: drive.py From SDRC with GNU General Public License v3.0 | 6 votes |
def __init__(self): GPIO.setmode(GPIO.BOARD) GPIO.setwarnings(False) GPIO.setup(self.MotorFront1, GPIO.OUT) GPIO.setup(self.MotorFront2, GPIO.OUT) GPIO.setup(self.MotorFront, GPIO.OUT) GPIO.output(self.MotorFront, 0) GPIO.setup(self.MotorBack1, GPIO.OUT) GPIO.setup(self.MotorBack2, GPIO.OUT) GPIO.setup(self.MotorBack, GPIO.OUT) GPIO.output(self.MotorBack, 0) self.BackPWM = GPIO.PWM(self.MotorBack,100) self.BackPWM.start(0) self.BackPWM.ChangeDutyCycle(0) self.direction = 0
Example #6
Source File: steppertest.py From rpi-film-capture with MIT License | 6 votes |
def pulsetest(): dir=True for freq in [200, 400, 800, 1000]: halfpulse=.5/freq # for j in range(0,i): logging.debug("start") for i in range(0,1600): GPIO.output(pulse_pin, True) time.sleep(halfpulse) GPIO.output(pulse_pin, False) time.sleep(halfpulse) logging.debug("stop") dir=not dir GPIO.output(dir_pin, dir) time.sleep(.5) # logging.debug(i)
Example #7
Source File: control.py From rpi-film-capture with MIT License | 6 votes |
def __init__(self): GPIO.setmode(GPIO.BCM) GPIO.setup(self.dir_pin, GPIO.OUT) GPIO.setup(self.pulse_pin, GPIO.OUT) GPIO.setup(self.ms1_pin, GPIO.OUT) GPIO.setup(self.ms2_pin, GPIO.OUT) GPIO.setup(self.sleep_pin, GPIO.OUT) GPIO.setup(self.reset_pin, GPIO.OUT) dir=False GPIO.output(self.dir_pin, dir) GPIO.output(self.pulse_pin, False) GPIO.output(self.ms1_pin, True) GPIO.output(self.ms2_pin, False) GPIO.output(self.sleep_pin, False) GPIO.output(self.reset_pin, True) self.p1 = GPIO.PWM(self.pulse_pin, self.pulse_freq)
Example #8
Source File: hx711.py From hx711py with Apache License 2.0 | 6 votes |
def power_down(self): # Wait for and get the Read Lock, incase another thread is already # driving the HX711 serial interface. self.readLock.acquire() # Cause a rising edge on HX711 Digital Serial Clock (PD_SCK). We then # leave it held up and wait 100 us. After 60us the HX711 should be # powered down. GPIO.output(self.PD_SCK, False) GPIO.output(self.PD_SCK, True) time.sleep(0.0001) # Release the Read Lock, now that we've finished driving the HX711 # serial interface. self.readLock.release()
Example #9
Source File: hx711.py From hx711py with Apache License 2.0 | 6 votes |
def power_up(self): # Wait for and get the Read Lock, incase another thread is already # driving the HX711 serial interface. self.readLock.acquire() # Lower the HX711 Digital Serial Clock (PD_SCK) line. GPIO.output(self.PD_SCK, False) # Wait 100 us for the HX711 to power back up. time.sleep(0.0001) # Release the Read Lock, now that we've finished driving the HX711 # serial interface. self.readLock.release() # HX711 will now be defaulted to Channel A with gain of 128. If this # isn't what client software has requested from us, take a sample and # throw it away, so that next sample from the HX711 will be from the # correct channel/gain. if self.get_gain() != 128: self.readRawBytes()
Example #10
Source File: mymodem.py From genmon with GNU General Public License v2.0 | 6 votes |
def InitHardware(self): # NOTE: This function assumes the underlying hardware is the LTE Cat 1 Pi Hat # http://wiki.seeedstudio.com/LTE_Cat_1_Pi_HAT/ try: self.power_pin = 29 self.reset_pin = 31 GPIO.setmode(GPIO.BOARD) GPIO.setwarnings(False) GPIO.setup(self.power_pin, GPIO.OUT) # Setup module power pin GPIO.setup(self.reset_pin, GPIO.OUT) # Setup module reset pin GPIO.output(self.power_pin, False) GPIO.output(self.reset_pin, False) return self.PowerUp() except Exception as e1: self.LogErrorLine("Error in LTEPiHat:InitHardware: " + str(e1)) return False #------------------LTEPiHat::PowerDown-------------------------------------
Example #11
Source File: mymodem.py From genmon with GNU General Public License v2.0 | 6 votes |
def EnableRTSCTS(self): try: process = Popen(['rpirtscts', 'on'], stdout=PIPE) output, _error = process.communicate() if _error == None: return True else: self.LogError("Error running rpirtscts in EnableRTSCTS: " + str(_error) ) return False except Exception as e1: self.LogErrorLine("Error in EnableRTSCTS: " + str(e1)) self.LogError("Output: " + str(output)) self.LogError("Error: " + str(_error)) return False #------------------LTEPiHat::DisableRTSCTS----------------------------------
Example #12
Source File: mymodem.py From genmon with GNU General Public License v2.0 | 6 votes |
def DisableRTSCTS(self): try: process = Popen(['rpirtscts', 'off'], stdout=PIPE) output, _error = process.communicate() if _error == None: return True else: self.LogError("Error running rpirtscts in DisableRTSCTS: " + str(_error) ) return False except Exception as e1: self.LogErrorLine("Error in DisableRTSCTS: " + str(e1)) self.LogError("Output: " + str(output)) self.LogError("Error: " + str(_error)) return False #------------------LTEPiHat::Close------------------------------------------
Example #13
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 #14
Source File: digital_display.py From SAKS-SDK with GNU General Public License v2.0 | 6 votes |
def flush_bit(self, sel, num, dp): if num == '#': num = 10 elif num == '-': num = 11 else: num = int(num) GPIO.output(self.__pins['sel'][sel], self.__real_true) n = self.__number_code[num] if dp: n = n | 10000000 for i in range(8): if (n & (1 << i)): GPIO.output(self.__pins['seg'][i], self.__real_true) GPIO.output(self.__pins['sel'][sel], not self.__real_true) for i in self.__pins['seg']: GPIO.output(i, not self.__real_true)
Example #15
Source File: mymodem.py From genmon with GNU General Public License v2.0 | 5 votes |
def TogglePower(self): GPIO.output(self.power_pin, True) time.sleep(1.5) GPIO.output(self.power_pin, False) #------------------LTEPiHat::PowerUp----------------------------------------
Example #16
Source File: rrb3.py From raspirobotboard3 with MIT License | 5 votes |
def set_led2(self, state): GPIO.output(self.LED2_PIN, state)
Example #17
Source File: rrb3.py From raspirobotboard3 with MIT License | 5 votes |
def set_led1(self, state): GPIO.output(self.LED1_PIN, state)
Example #18
Source File: controller_rpi.py From SX127x_driver_for_MicroPython_on_ESP8266 with GNU General Public License v3.0 | 5 votes |
def prepare_pin(self, pin_id, in_out = GPIO.OUT): if pin_id is not None: GPIO.setup(pin_id, in_out) new_pin = Controller.Mock() new_pin.pin_id = pin_id if in_out == GPIO.OUT: new_pin.low = lambda : GPIO.output(pin_id, GPIO.LOW) new_pin.high = lambda : GPIO.output(pin_id, GPIO.HIGH) else: new_pin.value = lambda : GPIO.input(pin_id) return new_pin
Example #19
Source File: epd.py From rpi_epd2in7 with MIT License | 5 votes |
def digital_write(self, pin, value): return GPIO.output(pin, value)
Example #20
Source File: tm1637.py From raspberrypi-examples with MIT License | 5 votes |
def start(self): """send start signal to TM1637""" IO.output(self.__Clkpin, IO.HIGH) IO.output(self.__Datapin, IO.HIGH) IO.output(self.__Datapin, IO.LOW) IO.output(self.__Clkpin, IO.LOW)
Example #21
Source File: rrb3.py From raspirobotboard3 with MIT License | 5 votes |
def set_driver_pins(self, left_pwm, left_dir, right_pwm, right_dir): self.left_pwm.ChangeDutyCycle(left_pwm * 100 * self.pwm_scale) GPIO.output(self.LEFT_1_PIN, left_dir) GPIO.output(self.LEFT_2_PIN, not left_dir) self.right_pwm.ChangeDutyCycle(right_pwm * 100 * self.pwm_scale) GPIO.output(self.RIGHT_1_PIN, right_dir) GPIO.output(self.RIGHT_2_PIN, not right_dir)
Example #22
Source File: ultrasonic-distance.py From raspberrypi-examples with MIT License | 5 votes |
def setup(): GPIO.setwarnings(False) GPIO.setmode(GPIO.BCM) GPIO.setup(pecho, GPIO.IN, pull_up_down=GPIO.PUD_DOWN) GPIO.setup(ptrig, GPIO.OUT) GPIO.output(ptrig, 0)
Example #23
Source File: controller_rpi.py From SX127x_driver_for_MicroPython_on_ESP8266 with GNU General Public License v3.0 | 5 votes |
def prepare_pin(self, pin_id, in_out = GPIO.OUT): if pin_id is not None: GPIO.setup(pin_id, in_out) new_pin = Controller.Mock() new_pin.pin_id = pin_id if in_out == GPIO.OUT: new_pin.low = lambda: GPIO.output(pin_id, GPIO.LOW) new_pin.high = lambda: GPIO.output(pin_id, GPIO.HIGH) else: new_pin.value = lambda: GPIO.input(pin_id) return new_pin
Example #24
Source File: rrb3.py From raspirobotboard3 with MIT License | 5 votes |
def set_oc2(self, state): GPIO.output(self.OC2_PIN, state)
Example #25
Source File: rrb3.py From raspirobotboard3 with MIT License | 5 votes |
def set_driver_pins(self, left_pwm, left_dir, right_pwm, right_dir): self.left_pwm.ChangeDutyCycle(left_pwm * 100 * self.pwm_scale) GPIO.output(self.LEFT_1_PIN, left_dir) GPIO.output(self.LEFT_2_PIN, not left_dir) self.right_pwm.ChangeDutyCycle(right_pwm * 100 * self.pwm_scale) GPIO.output(self.RIGHT_1_PIN, right_dir) GPIO.output(self.RIGHT_2_PIN, not right_dir)
Example #26
Source File: rrb3.py From raspirobotboard3 with MIT License | 5 votes |
def set_led1(self, state): GPIO.output(self.LED1_PIN, state)
Example #27
Source File: rrb3.py From raspirobotboard3 with MIT License | 5 votes |
def set_led2(self, state): GPIO.output(self.LED2_PIN, state)
Example #28
Source File: rrb3.py From raspirobotboard3 with MIT License | 5 votes |
def set_oc1(self, state): GPIO.output(self.OC1_PIN, state)
Example #29
Source File: rrb3.py From raspirobotboard3 with MIT License | 5 votes |
def set_oc2(self, state): GPIO.output(self.OC2_PIN, state)
Example #30
Source File: rrb3.py From raspirobotboard3 with MIT License | 5 votes |
def set_oc1(self, state): GPIO.output(self.OC1_PIN, state)