def eeprom_write_byte(addr, byte, smb, slaveaddr, writestrobe, chip) :

    haddr = 0x00 + addr
    hslaveaddr = 0x00 + slaveaddr

    if (chip <= 2) :
        data = [byte]
        try:
            rGPIO.output(writestrobe, rGPIO.LOW)
            smb.write_i2c_block_data(hslaveaddr, addr%256, data)
            rGPIO.output(writestrobe, rGPIO.HIGH)
        finally:
            time.sleep(0.015)
    elif (chip > 2 and chip <= 5) :
        data = [byte]
        hslaveaddr = hslaveaddr | addr//256
        try:
            rGPIO.output(writestrobe, rGPIO.LOW)
            smb.write_i2c_block_data(hslaveaddr, addr%256, data)
            rGPIO.output(writestrobe, rGPIO.HIGH)
        finally:
            time.sleep(0.015) # data sheet says 10 msec mac
    elif (chip > 5 and chip <= 10) :
        data = [addr%256,byte]
        try:
            rGPIO.output(writestrobe, rGPIO.LOW)
            smb.write_i2c_block_data(slaveaddr, addr//256, data)
            rGPIO.output(writestrobe, rGPIO.HIGH)
        finally:
            time.sleep(0.015)
    else :
        data = [addr%256,byte]
        hslaveaddr = hslaveaddr | addr//65535
        try:
            rGPIO.output(writestrobe, rGPIO.LOW)
            smb.write_i2c_block_data(hslaveaddr, addr//256, data)
            rGPIO.outpu(writestrobe, rGPIO.HIGH)
        finally:
            time.sleep(0.015)
		elif message.note == msg80_OFF.note:
			#GPIO.output(R1, GPIO.LOW)
			print "De-activate solenoid"
			sleep(1)
			print message
		elif message.note == msg81_OFF.note:
			GPIO.output(R3, GPIO.LOW)
			print "De-activate solenoid"
			sleep(1)
			print message
		elif message.note == msg82_OFF.note:
			#GPIO.output(R1, GPIO.LOW)
			print "De-activate solenoid"
			sleep(1)
			print message
		elif message.note == msg83_OFF.note:
			GPIO.output(R4, GPIO.LOW)
			print "De-activate solenoid"
			sleep(1)
			print message
		elif message.note == msg84_OFF.note:
			GPIO.outpu(R5, GPIO.LOW)
			print "De-activate solenoid"
			sleep(1)
			print message

GPIO.cleanup()

###############################################################################			
		
Ejemplo n.º 3
0
	c2=b
	c3=c
	c4=d
	print 'count c1=',c1
	print 'count c2=',c2
	print 'count c3=',c3
	print 'count c4=',c4
	t=[4,4,4,6,6,20,24,28,32,36,40]#delay determining array
	
	for y in range(0,4):
		if ((c1>=c2)and(c1>=c3)and(c1>=c4)):
			print 'timer1 on for '
			x=t[c1]
			print x
			c1=0
			GPIO.outpu(21,True)#RED4
			GPIO.output(5,False)#RED1
			GPIO.output(13,True)#RED2
			GPIO.output(7,True)#GREEN1
			GPIO.output(12,True)#RED3
			time.sleep(x)
			GPIO.output(7,False)#GREEN1OFF
			GPIO.outpu(3,True)#YELLOW1
			time.sleep(3)
			GPIO.output(5,True)#RED1
			elif ((c2>=c1)and(c2>=c3)and(c2>=c4)):
				print 'time2 on for '
				x=t[c2]
				print x
				c2=0
				GPIO.outpu(21,True)#RED4
Ejemplo n.º 4
0
					Current_RightHandPos = RS3		#change this
					print message
			elif message.note == msg84_ON.note:
				#move stepper to position R1
				sleep(0.2)
				print "Hand was moved"
				GPIO.output(R1, GPIO.HIGH)
				sleep(1)
				print message
	elif message.type == ('note_off'):
		if message.note == msg24_OFF.note:
			GPIO.output(L1, GPIO.LOW)
			print "R1 Solenoid De-activated"
			sleep(1)
			print message
		elif message.note == msg60_OFF.note:
			GPIO.output(R1, GPIO.LOW)
			print "De-activate solenoid"
			sleep(1)
			print message
		elif message.note == msg84_OFF.note:
			GPIO.outpu(R1, GPIO.LOW)
			print "De-activate solenoid"
			sleep(1)
			print message

GPIO.cleanup()

		
		
Ejemplo n.º 5
0
import RPi.GPIO as GPIO
import time

RED_PIN = 17

GPIO.setmode(GPIO.BCM)
GPIO.setup(RED_PIN,GPIO.OUT)
GPIO.setwarnings(False)
try:
	for i in range(0, 10):
		GPIO.output(RED_PIN,True)
		time.sleep(1)
		GPIO.outpu(RED_PIN,False)
		time.sleep(1)

except:
  print("exception")


finally:
   GPIO.cleanup()
   print("cleanup executed")
Ejemplo n.º 6
0
# DECLARE variables! 
mypin1 = 21 # GPIO pin 21

# SETUP!
# set GPIO layout - pin numbering convention (BCM or number)
GPIO.setmode(GPIO.BCM)
GPIO.setup(mypin1, GPIO.OUT)

#define a function for the thread
def toggleLED( threadName, delay, mypin):
    count = 0
    while count < 5:
        time.sleep(delay)
        count+=1
        print "%s: %s" %( threadName, time.ctime(time.time()) )
        GPIO.output(mypin, True) # toggle ON pin
        time.sleep(delay)        # wait some time (s)
        GPIO.output(mypin, False) # toggle OFF pin 
        

# LOOP!
# create 2 threads as follows
delay_time = 1 # 1 second pause
while True:
    GPIO.output(mypin, True)
    time.sleep(delay_time)
    GPIO.outpu(mypin, False)
    time.sleep(delay_time)