Python RPi.GPIO.HIGH Examples

The following are 30 code examples of RPi.GPIO.HIGH(). 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: sakshat.py    From SAKS-SDK with GNU General Public License v2.0 6 votes vote down vote up
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 #2
Source File: ex1_kwstest.py    From ai-makers-kit with MIT License 6 votes vote down vote up
def btn_detect():
	global btn_status
	with MicrophoneStream(RATE, CHUNK) as stream:
		audio_generator = stream.generator()

		for content in audio_generator:
			GPIO.output(31, GPIO.HIGH)
			rc = ktkws.detect(content)
			rms = audioop.rms(content,2)
			#print('audio rms = %d' % (rms))
			GPIO.output(31, GPIO.LOW)
			if (btn_status == True):
				rc = 1
				btn_status = False			
			if (rc == 1):
				GPIO.output(31, GPIO.HIGH)
				play_file("../data/sample_sound.wav")
				return 200 
Example #3
Source File: proj2_yt_mvp.py    From ai-makers-kit with MIT License 6 votes vote down vote up
def detect():
	global button
	with MicrophoneStream(RATE, CHUNK) as stream:
		audio_generator = stream.generator()

		for content in audio_generator:
			#import binascii
			#print ("INBYTE: %s" % (binascii.hexlify(bytearray(content))))
			GPIO.output(31, GPIO.HIGH)
			rc = ktkws.detect(content)
			rms = audioop.rms(content,2)
			#print('audio rms = %d' % (rms))
			GPIO.output(31, GPIO.LOW)
			if (button == True):
				rc = 1
				button = False
			
			if (rc == 1):
				GPIO.output(31, GPIO.HIGH)
				play_file("../data/sample_sound.wav")
				return 200 
Example #4
Source File: proj3_capital_game.py    From ai-makers-kit with MIT License 6 votes vote down vote up
def detect():
	global button
	with MicrophoneStream(RATE, CHUNK) as stream:
		audio_generator = stream.generator()

		for content in audio_generator:
			#import binascii
			#print ("INBYTE: %s" % (binascii.hexlify(bytearray(content))))
			GPIO.output(31, GPIO.HIGH)
			rc = ktkws.detect(content)
			rms = audioop.rms(content,2)
			#print('audio rms = %d' % (rms))
			GPIO.output(31, GPIO.LOW)
			if (button == True):
				rc = 1
				button = False
			
			if (rc == 1):
				GPIO.output(31, GPIO.HIGH)
				gt2vt.play_file("../data/sample_sound.wav")
				return 200 
Example #5
Source File: smart_trash_can.py    From ai-makers-kit with MIT License 6 votes vote down vote up
def detect():
	global button
	with MicrophoneStream(RATE, CHUNK) as stream:
		audio_generator = stream.generator()

		for content in audio_generator:
			#import binascii
			#print ("INBYTE: %s" % (binascii.hexlify(bytearray(content))))
			GPIO.output(31, GPIO.HIGH)
			rc = ktkws.detect(content)
			rms = audioop.rms(content,2)
			#print('audio rms = %d' % (rms))
			GPIO.output(31, GPIO.LOW)
			if (button == True):
				rc = 1
				button = False
			
			if (rc == 1):
				GPIO.output(31, GPIO.HIGH)
				gt2vt.play_file("../data/sample_sound.wav")
				return 200 
Example #6
Source File: ex1_kwstest.py    From ai-makers-kit with MIT License 6 votes vote down vote up
def btn_detect():
	global btn_status
	with MS.MicrophoneStream(RATE, CHUNK) as stream:
		audio_generator = stream.generator()

		for content in audio_generator:
			GPIO.output(31, GPIO.HIGH)
			rc = ktkws.detect(content)
			rms = audioop.rms(content,2)
			#print('audio rms = %d' % (rms))
			GPIO.output(31, GPIO.LOW)
			if (btn_status == True):
				rc = 1
				btn_status = False			
			if (rc == 1):
				GPIO.output(31, GPIO.HIGH)
				MS.play_file("../data/sample_sound.wav")
				return 200 
Example #7
Source File: digital_display.py    From SAKS-SDK with GNU General Public License v2.0 6 votes vote down vote up
def __init__(self, pins, real_true = GPIO.HIGH):
        '''
        Init the digital display
        :param pin: pin numbers in array
        :param real_true: GPIO.HIGH or GPIO.LOW
        :return: void
        '''
        self.__pins = pins
        self.__real_true = real_true
        try:
            t1 = Thread(target = self.flush_4bit)
            t1.setDaemon(True)
            t1.start()
        except:
            print("Error: Unable to start thread by DigitalDisplay")

    #Stauts. 
Example #8
Source File: smart_trash_can.py    From ai-makers-kit with MIT License 6 votes vote down vote up
def detect():
	global button
	with MicrophoneStream(RATE, CHUNK) as stream:
		audio_generator = stream.generator()

		for content in audio_generator:
			#import binascii
			#print ("INBYTE: %s" % (binascii.hexlify(bytearray(content))))
			GPIO.output(31, GPIO.HIGH)
			rc = ktkws.detect(content)
			rms = audioop.rms(content,2)
			#print('audio rms = %d' % (rms))
			GPIO.output(31, GPIO.LOW)
			if (button == True):
				rc = 1
				button = False
			
			if (rc == 1):
				GPIO.output(31, GPIO.HIGH)
				gt2vt.play_file("../data/sample_sound.wav")
				return 200 
Example #9
Source File: epd.py    From Waveshare-E-Ink with MIT License 6 votes vote down vote up
def _writeDisplayRam(self, xsize, ysize, data):
    if xsize % 8 != 0:
      xsize = xsize + (8 - xsize % 8)
    xsize /= 8

    self._readBusy()
    GPIO.output(DC, GPIO.LOW)
    self._spi.writebytes([0x24])
    GPIO.output(DC, GPIO.HIGH)

    size = int(xsize * ysize)
    if not isinstance(data, list):
      data = [data] * size

    # SPI buffer size default: 4096 bytes
    i = 0
    for i in range(0, int(size/4096)):
      self._spi.writebytes(data[i:i+4096])
      i += 4096
    self._spi.writebytes(data[i:size]) 
Example #10
Source File: epd.py    From Waveshare-E-Ink with MIT License 6 votes vote down vote up
def _init(self):
    # Initialize display
    # Reset driver
    GPIO.output(CS, GPIO.LOW)
    GPIO.output(RST, GPIO.HIGH)
    time.sleep(0.1)
    GPIO.output(RST, GPIO.LOW)
    time.sleep(0.01)
    GPIO.output(RST, GPIO.HIGH)

    # Set register
    self._write(gdo_control)  # Pannel configuration, Gate selection
    self._write(soft_start)   # X decrease, Y decrease
    self._write(vcom_vol)     # VCOM setting
    self._write(dummy_line)   # dummy line per gate
    self._write(gate_time)    # Gage time setting
    self._write(ram_data_entry_mode)  # X increase, Y decrease

    # X-source area, Y-gage area
    xdot = self._xDot-1
    ydot = self._yDot-1
    self._setRamArea(0x00, int(xdot/8), ydot%256, int(ydot/256), 0x00, 0x00)
    self._setRamPointer(0x00, ydot%256, int(ydot/256)) # set ram 
Example #11
Source File: AMSpi.py    From AMSpi with MIT License 6 votes vote down vote up
def _shift_write(self, value):
        """
        Write given value to the shift register

        :param int value: value which you want to write to shift register
        """
        if self._test_shift_pins() is False:
            print("ERROR: PINs for shift register were not set properly.")
            self.__exit__(None, None, None)

        GPIO.output(self._DIR_LATCH, GPIO.LOW)
        for x in range(0, 8):
            temp = value & 0x80
            GPIO.output(self._DIR_CLK, GPIO.LOW)
            if temp == 0x80:
                # data bit HIGH
                GPIO.output(self._DIR_SER, GPIO.HIGH)
            else:
                # data bit LOW
                GPIO.output(self._DIR_SER, GPIO.LOW)
            GPIO.output(self._DIR_CLK, GPIO.HIGH)
            value <<= 0x01  # shift left

        GPIO.output(self._DIR_LATCH, GPIO.HIGH) 
Example #12
Source File: tm1637.py    From raspberrypi-examples with MIT License 6 votes vote down vote up
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 #13
Source File: GPIO.py    From Adafruit_Python_GPIO with MIT License 5 votes vote down vote up
def input(self, pin):
        """Read the specified pin and return HIGH/true if the pin is pulled high,
        or LOW/false if pulled low."""
        raise NotImplementedError 
Example #14
Source File: interface.py    From epd-library-python with GNU General Public License v3.0 5 votes vote down vote up
def __init__(self, vcom=-1.5):

        # check that we are root
        self.early_exit = False
        if geteuid() != 0:
            print("***EPD controller must be run as root!***")
            self.early_exit = True
            exit()

        self.spi = SPI()

        GPIO.setmode(GPIO.BCM)
        GPIO.setwarnings(False)
        GPIO.setup(Pins.HRDY, GPIO.IN, pull_up_down=GPIO.PUD_DOWN)
        GPIO.setup(Pins.RESET, GPIO.OUT, initial=GPIO.HIGH)

        # reset
        GPIO.output(Pins.RESET, GPIO.LOW)
        sleep(0.1)
        GPIO.output(Pins.RESET, GPIO.HIGH)

        self.width            = None
        self.height           = None
        self.img_buf_address  = None
        self.firmware_version = None
        self.lut_version      = None
        self.update_system_info()

        self._set_img_buf_base_addr(self.img_buf_address)

        # enable I80 packed mode
        self.write_register(Registers.I80CPCR, 0x1)

        self.set_vcom(vcom) 
Example #15
Source File: epd1in54c.py    From epd-library-python with GNU General Public License v3.0 5 votes vote down vote up
def send_data(self, data):
        self.digital_write(self.dc_pin, GPIO.HIGH)
        # the parameter type is list but not int
        # so use [data] instead of data
        epdif.spi_transfer([data]) 
Example #16
Source File: GPIO.py    From Adafruit_Python_GPIO with MIT License 5 votes vote down vote up
def set_high(self, pin):
        """Set the specified pin HIGH."""
        self.output(pin, HIGH) 
Example #17
Source File: GPIO.py    From Adafruit_Python_GPIO with MIT License 5 votes vote down vote up
def input_pins(self, pins):
        """Read multiple pins specified in the given list and return list of pin values
        GPIO.HIGH/True if the pin is pulled high, or GPIO.LOW/False if pulled low.
        """
        # General implementation that can be optimized by derived classes.
        return [self.input(pin) for pin in pins] 
Example #18
Source File: GPIO.py    From Adafruit_Python_GPIO with MIT License 5 votes vote down vote up
def output_pins(self, pins):
        """Set multiple pins high or low at once.  Pins should be a dict of pin
        name to pin value (HIGH/True for 1, LOW/False for 0).  All provided pins
        will be set to the given values.
        """
        # General implementation just loops through pins and writes them out
        # manually.  This is not optimized, but subclasses can choose to implement
        # a more optimal batch output implementation.  See the MCP230xx class for
        # example of optimized implementation.
        for pin, value in iter(pins.items()):
            self.output(pin, value) 
Example #19
Source File: GPIO.py    From Adafruit_Python_GPIO with MIT License 5 votes vote down vote up
def input(self, pin):
        """Read the specified pin and return HIGH/true if the pin is pulled high,
        or LOW/false if pulled low.
        """
        return self.rpi_gpio.input(pin) 
Example #20
Source File: epd4in2b.py    From epd-library-python with GNU General Public License v3.0 5 votes vote down vote up
def send_data(self, data):
        self.digital_write(self.dc_pin, GPIO.HIGH)
        # the parameter type is list but not int
        # so use [data] instead of data
        epdif.spi_transfer([data]) 
Example #21
Source File: epd9in7.py    From epd-library-python with GNU General Public License v3.0 5 votes vote down vote up
def reset(self):
        self.digital_write(self.reset_pin, GPIO.LOW)         # module reset
        self.delay_ms(200)
        self.digital_write(self.reset_pin, GPIO.HIGH)
        self.delay_ms(200) 
Example #22
Source File: epd9in7.py    From epd-library-python with GNU General Public License v3.0 5 votes vote down vote up
def send_data(self, data):
        self.digital_write(self.dc_pin, GPIO.HIGH)
        # the parameter type is list but not int
        # so use [data] instead of data
        epdif.spi_transfer([data]) 
Example #23
Source File: epd2in7.py    From epd-library-python with GNU General Public License v3.0 5 votes vote down vote up
def send_data(self, data):
        self.digital_write(self.dc_pin, GPIO.HIGH)
        # the parameter type is list but not int
        # so use [data] instead of data
        epdif.spi_transfer([data]) 
Example #24
Source File: epd2in13.py    From epd-library-python with GNU General Public License v3.0 5 votes vote down vote up
def reset(self):
        self.digital_write(self.reset_pin, GPIO.LOW)         # module reset
        self.delay_ms(200)
        self.digital_write(self.reset_pin, GPIO.HIGH)
        self.delay_ms(200)    

##
 #  @brief: set the look-up table register
 ## 
Example #25
Source File: epd2in13.py    From epd-library-python with GNU General Public License v3.0 5 votes vote down vote up
def send_data(self, data):
        self.digital_write(self.dc_pin, GPIO.HIGH)
        # the parameter type is list but not int
        # so use [data] instead of data
        epdif.spi_transfer([data]) 
Example #26
Source File: epd2in9.py    From epd-library-python with GNU General Public License v3.0 5 votes vote down vote up
def reset(self):
        self.digital_write(self.reset_pin, GPIO.LOW)         # module reset
        self.delay_ms(200)
        self.digital_write(self.reset_pin, GPIO.HIGH)
        self.delay_ms(200)    

##
 #  @brief: set the look-up table register
 ## 
Example #27
Source File: epd2in9.py    From epd-library-python with GNU General Public License v3.0 5 votes vote down vote up
def send_data(self, data):
        self.digital_write(self.dc_pin, GPIO.HIGH)
        # the parameter type is list but not int
        # so use [data] instead of data
        epdif.spi_transfer([data]) 
Example #28
Source File: epd2in13b.py    From epd-library-python with GNU General Public License v3.0 5 votes vote down vote up
def send_data(self, data):
        self.digital_write(self.dc_pin, GPIO.HIGH)
        # the parameter type is list but not int
        # so use [data] instead of data
        epdif.spi_transfer([data]) 
Example #29
Source File: epd7in5b.py    From epd-library-python with GNU General Public License v3.0 5 votes vote down vote up
def reset(self):
        self.digital_write(self.reset_pin, GPIO.LOW)         # module reset
        self.delay_ms(200)
        self.digital_write(self.reset_pin, GPIO.HIGH)
        self.delay_ms(200) 
Example #30
Source File: epd7in5b.py    From epd-library-python with GNU General Public License v3.0 5 votes vote down vote up
def send_data(self, data):
        self.digital_write(self.dc_pin, GPIO.HIGH)
        # the parameter type is list but not int
        # so use [data] instead of data
        epdif.spi_transfer([data])