def shiftRegisters(number): if MODE == "production": shiftpi.shiftRegisters(number) else: print "Using " + str(number) + " register(s)" return 1
#import shiftpi import shiftpi.shiftpi as shiftpi shiftpi.shiftRegisters(8) #initialize shiftpi.digitalWrite(shiftpi.ALL, shiftpi.LOW) shiftpi.delay(1000) # turns shift register's pin to HIGH shiftpi.digitalWrite(44, shiftpi.HIGH) shiftpi.delay(500) shiftpi.digitalWrite(45, shiftpi.HIGH) shiftpi.delay(500) shiftpi.digitalWrite(46, shiftpi.HIGH) shiftpi.delay(500) # turns shift register's pin to LOW shiftpi.digitalWrite(44, shiftpi.LOW) shiftpi.delay(500) # turns all shift register pins to HIGH shiftpi.digitalWrite(shiftpi.ALL, shiftpi.HIGH) shiftpi.delay(1000) #and to low shiftpi.digitalWrite(shiftpi.ALL, shiftpi.LOW) shiftpi.delay(1000)
# import the things import shiftpi.shiftpi as sp # Number of 595n # 1-32 2 lights per bit # 33 37 41 45 single lights # 34-36 38-40 42-44 46-48 rgb lights sp.shiftRegisters(6) # lights go up and down either side of hearts # ========================= # def slide(): sp.digitalWrite(1, sp.HIGH) sp.digitalWrite(8, sp.HIGH) sp.digitalWrite(17, sp.HIGH) sp.digitalWrite(25, sp.HIGH) sp.delay(75) sp.digitalWrite(2, sp.HIGH) sp.digitalWrite(9, sp.HIGH) sp.digitalWrite(18, sp.HIGH) sp.digitalWrite(26, sp.HIGH) sp.delay(75) sp.digitalWrite(1, sp.LOW) sp.digitalWrite(8, sp.LOW) sp.digitalWrite(17, sp.LOW) sp.digitalWrite(25, sp.LOW) sp.delay(75) sp.digitalWrite(3, sp.HIGH) sp.digitalWrite(10, sp.HIGH) sp.digitalWrite(19, sp.HIGH) sp.digitalWrite(27, sp.HIGH) sp.delay(75) sp.digitalWrite(2, sp.LOW)
# G E D A C dp B F segments = [ [-1, 1, 2, 3, 4, -1, 6, 7], # 0 [-1, -1, -1, -1, 4, -1, 6, -1], # 1 [0, 1, 2, 3, -1, -1, 6, -1], # 2 [0, -1, 2, 3, 4, -1, 6, -1], # 3 [0, -1, -1, -1, 4, -1, 6, 7], # 4 [0, -1, 2, 3, 4, -1, -1, 7], # 5 [0, 1, 2, 3, 4, -1, -1, 7], # 6 [-1, -1, -1, 3, 4, -1, 6, -1], # 7 [0, 1, 2, 3, 4, -1, 6, 7], # 8 [0, -1, 2, 3, 4, -1, 6, 7] ] # 9 SP.shiftRegisters(4) if len(sys.argv) == 1: digit = 4 col = 0 elif len(sys.argv) == 2: digit = int(sys.argv[1]) col = 0 else: digit = int(sys.argv[1]) col = int(sys.argv[2]) if digit > 9 or digit < 0: SP.digitalWrite(SP.ALL, SP.LOW) sys.exit("invalid digit") if col < 0 or col > 3: SP.digitalWrite(SP.ALL, SP.LOW)
#import shiftpi import shiftpi.shiftpi as shiftpi shiftpi.shiftRegisters(8) #initialize shiftpi.digitalWrite(shiftpi.ALL, shiftpi.LOW) shiftpi.delay(1000) # turns shift register's pin to HIGH shiftpi.digitalWrite(44, shiftpi.HIGH) shiftpi.delay(500) shiftpi.digitalWrite(45, shiftpi.HIGH) shiftpi.delay(500) shiftpi.digitalWrite(46, shiftpi.HIGH) shiftpi.delay(500) # turns shift register's pin to LOW shiftpi.digitalWrite(44, shiftpi.LOW) shiftpi.delay(500) # turns all shift register pins to HIGH shiftpi.digitalWrite(shiftpi.ALL, shiftpi.HIGH) shiftpi.delay(1000) #and to low shiftpi.digitalWrite(shiftpi.ALL, shiftpi.LOW)
print("setting pins") # Set pins as input or output GPIO.setup(left_joystick_up, GPIO.IN, pull_up_down=GPIO.PUD_UP) GPIO.setup(left_joystick_down, GPIO.IN, pull_up_down=GPIO.PUD_UP) GPIO.setup(right_joystick_up, GPIO.IN, pull_up_down=GPIO.PUD_UP) GPIO.setup(right_joystick_down, GPIO.IN, pull_up_down=GPIO.PUD_UP) GPIO.setup(start_button, GPIO.IN, pull_up_down=GPIO.PUD_UP) shiftpi.pinsSetup( **{ "ser": shift_register_SER, "rclk": shift_register_RCLK, "srclk": shift_register_SRCLK }) # Setting up LED configuration with shift registers shiftpi.shiftRegisters(2) # Light up all LEDs shiftpi.digitalWrite(shiftpi.ALL, shiftpi.HIGH) # Set up MCP23017 and configure inputs MCP = mcp_lib.MCP230XX('MCP23017', 0x20, '16bit') for input in range(0, 16): MCP.set_mode(input, 'input') standby = True flashing = False def motor_control(): global left_dir