def __init__(self, pinsRed, pinsGreen, sleepduration, callback_shoot, callback_reset, cid): threading.Thread.__init__(self) self._stop = threading.Event() # GPIO pins self.pinsRed = pinsRed self.pinsGreen = pinsGreen shiftpi.shiftRegisters(1) shiftpi.startupMode(shiftpi.HIGH, True) self.step = 0 self.flag = False self.sleepduration = sleepduration self.callback_shoot = callback_shoot self.callback_reset = callback_reset self.cid = cid
def __init__(self): shiftpi.pinsSetup(18, 23, 24) shiftpi.shiftRegisters(2) shiftpi.startupMode(shiftpi.LOW, True)
from shiftpi import (HIGH, LOW, ALL, digitalWrite, startupMode, delay, shiftRegisters) shiftRegisters(1) startupMode(LOW) up = 3 down = 4 try: while True: print('up') digitalWrite(up, HIGH) delay(500) digitalWrite(up, LOW) delay(6000) print('down') digitalWrite(down, HIGH) delay(500) digitalWrite(down, LOW) delay(6000) except KeyboardInterrupt: digitalWrite(ALL, LOW)
# You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. import datetime, time, shiftpi #from shiftpi import HIGH, LOW, digitalWrite, delay #import RPi.GPIO # Set the number of registers shiftpi.shiftRegisters(3) """Return an int This method will convert a given decimal number to binary, with the given number of leading 0's before the binary number. """ def decimalToBinary(num, leading): if num >= 0: return str(bin(num))[2:].zfill(leading) else: return "-" + str(bin(num)[3:].zfill(leading)) """Returns a map of ints
def __init__(self): ''' Constructor ''' shiftpi.shiftRegisters(2) self.turnAllOff()
#shiftpi.digitalWrite(7, shiftpi.HIGH) def testStuff(self, displayDigit): value = 'b' x = 1 result = {'a': lambda x: x * 5, 'b': lambda x: x + 7}[value](x) print value print x print result shiftpi.shiftRegisters(2) DELAY = 500 turnAllOn() #shiftpi.pinsSetup({"ser": SER_PIN, "rclk": RCLK_PIN, "srclk": SRCLK_PIN}) # that's itturnSegOn(0) #turnSegOn(1) #shiftpi.delay(2000) #turnSegOn(2) #turnSegOn(3) #turnSegOn(4) #turnSegOn(5) #turnSegOn(6) #turnAllOn() #turnAllOff() #turnAllOn() turnAllOff()
METHOD_CONTEXT = 0 TEMPERATURE_ALERT = 30.0 RECEIVE_CALLBACKS = 0 SEND_CALLBACKS = 0 BLOB_CALLBACKS = 0 TWIN_CALLBACKS = 0 SEND_REPORTED_STATE_CALLBACKS = 0 METHOD_CALLBACKS = 0 EVENT_SUCCESS = "success" EVENT_FAILED = "failed" # chose HTTP, AMQP or MQTT as transport protocol PROTOCOL = IoTHubTransportProvider.MQTT CONNECTION_STRING = 'HostName=uralchem-iot-hub.azure-devices.net;DeviceId=RaspberryPi_test_button;SharedAccessKey=QqLFpZw7rtElA87DZ/mx2dJ1KaCchA/wTFLgU1+EEI8=' MSG_TXT = "{\"deviceId\": \"RaspberryPi_test_button" "\",\"distance_1\": %f,\"distance_2\": %f,\"distance_3\": %f,\"distance_4\": %f,\"distance_5\": %f,\"distance_6\": %f,\"distance_7\": %f,\"distance_8\": %f,\"distance_9\": %f,\"distance_10\": %f}" shiftRegisters(3) # Create an object of the class MFRC522 #MIFAREReader = MFRC522.MFRC522() continue_reading = True # 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 # Hook the SIGINT signal.signal(signal.SIGINT, end_read)
def init(): shiftRegisters(3) digitalWrite(ALL, LOW) return 'initialized.'
subprocess.call(['./speech.sh',input]); else: call([cmd_beg+cmd_out+input+cmd_end], shell=True); pygame.mixer.init() pygame.mixer.music.load("Text.wav") pygame.mixer.music.play() if __name__ == '__main__': #print('Rasberry pi started.'); #GPIO, registers and espeak initial configuration #print('Configuring registers, buttons, espeak setting and GPIO configuration') cmd_beg='espeak -ven+f3 -k5 -s150 ' cmd_end=' | aplay /home/pi/Text.wav 2>/dev/null' cmd_out='--stdout > /home/pi/Text.wav ' shiftpi.shiftRegisters(6); shiftpi_char.shiftRegisters(1); GPIO.setmode(GPIO.BCM) GPIO.setup(26, GPIO.IN, pull_up_down=GPIO.PUD_UP) #Next Button to GPIO26 GPIO.setup(13, GPIO.IN, pull_up_down=GPIO.PUD_UP) #Previous Button to GPIO13 GPIO.setup(16, GPIO.IN, pull_up_down=GPIO.PUD_UP) #Voice Button to GPIO16 GPIO.setup(6, GPIO.IN, pull_up_down=GPIO.PUD_UP) #Random Button to GPIO6 GPIO.setup(5, GPIO.IN, pull_up_down=GPIO.PUD_UP) #Refresh Button to GPIO5 GPIO.setup(12, GPIO.IN, pull_up_down=GPIO.PUD_UP) #Change Button to GPIO12 #GPIO.setup(4,GPIO.OUT); #LED LIght #print('Registers and button configured successfully') #GPIO.output(4,GPIO.HIGH); #Intitial board configuration. Checks for connection. #If connection exists sets word mode from firebase #else gets to letter mode. internet_state=internetConnection();