Esempio n. 1
0
    except KeyboardInterrupt:
        print "Exit"
        GPIO.cleanup()  # clean up GPIO on CTRL+C exit

    GPIO.cleanup()  # clean up GPIO on normal exit


if __name__ == '__main__':

    #Riferimento ai GPIO per numero pin
    GPIO.setmode(GPIO.BOARD)
    #GPIO.setwarnings(False)

    RED = "J4.40"
    YELLOW = "J4.38"
    GREEN = "J4.36"

    GPIO.setup(RED, GPIO.OUT)
    GPIO.setup(YELLOW, GPIO.OUT)
    GPIO.setup(GREEN, GPIO.OUT)

    GPIO.output(RED, 0)
    GPIO.output(YELLOW, 0)
    GPIO.output(GREEN, 0)

    GPIO.pwm_export(0)
    GPIO.pwm_period(0, 20000000)

    main()
Esempio n. 2
0
def echo(bot, update):
    print "----> Mittente: : [" + update.message.from_user.username + "]"
    print "      Testo     : [" + update.message.text + "]"

    if update.message.text:
        if update.message.text == "RED ON":
            GPIO.output(RED, 1)
            bot.sendMessage(update.message.chat_id, text="Led rosso ON")

        if update.message.text == "RED OFF":
            GPIO.output(RED, 0)
            bot.sendMessage(update.message.chat_id, text="Led rosso OFF")

        if update.message.text == "YELLOW ON":
            GPIO.output(YELLOW, 1)
            bot.sendMessage(update.message.chat_id, text="Led giallo ON")

        if update.message.text == "YELLOW OFF":
            GPIO.output(YELLOW, 0)
            bot.sendMessage(update.message.chat_id, text="Led giallo OFF")

        if update.message.text == "GREEN ON":
            GPIO.output(GREEN, 1)
            bot.sendMessage(update.message.chat_id, text="Led verde ON")

        if update.message.text == "GREEN OFF":
            GPIO.output(GREEN, 0)
            bot.sendMessage(update.message.chat_id, text="Led verde OFF")

        if update.message.text == "LEFT":
            bot.sendMessage(update.message.chat_id, text="Servo a sinistra")
            GPIO.pwm_duty_cycle(0, 570000)
            GPIO.pwm_enable(0)
            time.sleep(1)
            GPIO.pwm_disable(0)

        if update.message.text == "CENTER":
            bot.sendMessage(update.message.chat_id, text="Servo al centro")
            GPIO.pwm_duty_cycle(0, 1490000)
            GPIO.pwm_enable(0)
            time.sleep(1)
            GPIO.pwm_disable(0)

        if update.message.text == "RIGHT":
            bot.sendMessage(update.message.chat_id, text="Servo a destra")
            GPIO.pwm_duty_cycle(0, 2410000)
            GPIO.pwm_enable(0)
            time.sleep(1)
            GPIO.pwm_disable(0)
Esempio n. 3
0
def echo(bot, update):
	print "----> Mittente: : [" + update.message.from_user.username + "]"
	print "      Testo     : [" + update.message.text + "]"
	
	if update.message.text:
		if update.message.text=="RED ON":
			GPIO.output(RED, 1)
			bot.sendMessage(update.message.chat_id, text="Led rosso ON")

		if update.message.text=="RED OFF":
			GPIO.output(RED, 0)
			bot.sendMessage(update.message.chat_id, text="Led rosso OFF")

		if update.message.text=="YELLOW ON":
			GPIO.output(YELLOW,1)
			bot.sendMessage(update.message.chat_id, text="Led giallo ON")

		if update.message.text=="YELLOW OFF":
			GPIO.output(YELLOW, 0)
			bot.sendMessage(update.message.chat_id, text="Led giallo OFF")

		if update.message.text=="GREEN ON":
			GPIO.output(GREEN,1)
			bot.sendMessage(update.message.chat_id, text="Led verde ON")

		if update.message.text=="GREEN OFF":
			GPIO.output(GREEN, 0)
			bot.sendMessage(update.message.chat_id, text="Led verde OFF")
Esempio n. 4
0
		# Run the bot until the you presses Ctrl-C or the process receives SIGINT,
		# SIGTERM or SIGABRT. This should be used most of the time, since
		# start_polling() is non-blocking and will stop the bot gracefully.
		updater.idle()

	except KeyboardInterrupt:  
		print "Exit"	
		GPIO.cleanup()       # clean up GPIO on CTRL+C exit  

	GPIO.cleanup()           # clean up GPIO on normal exit  	

if __name__ == '__main__':
	
	#Riferimento ai GPIO per numero pin
	GPIO.setmode(GPIO.BOARD)
	#GPIO.setwarnings(False)

	RED="J4.40"
	YELLOW="J4.38"
	GREEN="J4.36"

	GPIO.setup(RED, GPIO.OUT)
	GPIO.setup(YELLOW, GPIO.OUT)
	GPIO.setup(GREEN, GPIO.OUT)

	GPIO.output(RED, 0)
	GPIO.output(YELLOW, 0)
	GPIO.output(GREEN, 0)

	main()
Esempio n. 5
0
def echo(bot, update):
	print "----> Mittente: : [" + update.message.from_user.username + "]"
	print "      Testo     : [" + update.message.text + "]"
	
	if update.message.text:
		if update.message.text=="RED ON":
			GPIO.output(RED, 1)
			bot.sendMessage(update.message.chat_id, text="Led rosso ON")

		if update.message.text=="RED OFF":
			GPIO.output(RED, 0)
			bot.sendMessage(update.message.chat_id, text="Led rosso OFF")

		if update.message.text=="YELLOW ON":
			GPIO.output(YELLOW,1)
			bot.sendMessage(update.message.chat_id, text="Led giallo ON")

		if update.message.text=="YELLOW OFF":
			GPIO.output(YELLOW, 0)
			bot.sendMessage(update.message.chat_id, text="Led giallo OFF")

		if update.message.text=="GREEN ON":
			GPIO.output(GREEN,1)
			bot.sendMessage(update.message.chat_id, text="Led verde ON")

		if update.message.text=="GREEN OFF":
			GPIO.output(GREEN, 0)
			bot.sendMessage(update.message.chat_id, text="Led verde OFF")

		if update.message.text=="LEFT":
			bot.sendMessage(update.message.chat_id, text="Servo a sinistra")
			GPIO.pwm_duty_cycle(0,570000)
			GPIO.pwm_enable(0)			
			time.sleep(1)
			GPIO.pwm_disable(0)			
		
		if update.message.text=="CENTER":
			bot.sendMessage(update.message.chat_id, text="Servo al centro")
			GPIO.pwm_duty_cycle(0,1490000)
			GPIO.pwm_enable(0)			
			time.sleep(1)
			GPIO.pwm_disable(0)			

		if update.message.text=="RIGHT":
			bot.sendMessage(update.message.chat_id, text="Servo a destra")
			GPIO.pwm_duty_cycle(0,2410000)
			GPIO.pwm_enable(0)			
			time.sleep(1)
			GPIO.pwm_disable(0)			
Esempio n. 6
0
# Test GPIO
#***********************************************************************

print "Test GPIO"

# Ciclo di scansione e test dei GPIO

error_counter=0

for test in testlistPE20PE26:
	acmepins.setup(test[0],acmepins.OUT,0)
	acmepins.setup(test[1],acmepins.IN,0)
	if step == 1:
		print "%s -> %s" % (test[0],test[1])
		print "test0=1" 
	acmepins.output(test[0],1)
	if step == 1:
		raw_input("Press Enter")
	if acmepins.input(test[1])==0:
		print (color_warning + "%s=1 --> %s==1 ?" + color_normal) % (test[0],test[1]),
		print (color_warning + "Errore ! %s in corto verso massa oppure %s o %s a circuito aperto" + color_normal) % (test[1])
		error_counter = error_counter + 1
		if step == 1:
			raw_input(" Press Enter")
	acmepins.output(test[0],0)
	if step == 1:
		print "test0=0"
		raw_input("Press Enter")
	if acmepins.input(test[1])==1:
		print (color_warning + "%s=0 --> %s==0 ? " + color_normal) % (test[0],test[1]),
		print (color_warning + "Errore ! %s in corto verso 3V3 oppure %s o %s a circuito aperto" + color_normal) % (test[1], test[0], test[1])
Esempio n. 7
0
 def __send_and_sleep(self, output, sleep):
     GPIO.output(self.__pin, output)
     time.sleep(sleep)