def __init__(self, pin, hz):
     GPIO.setmode(GPIO.BOARD)
     GPIO.setup(pin, GPIO.OUT)
     servo = GPIO.PWM(pin, hz)
     servo.start(0)
     self.StartUp()
예제 #2
0
import PRi.GPIO as GPIO

GPIO.setmode(GPIO.BCM)

GPIO.setup(1, GPIO.IN)
GPIO.setup(2, GPIO.IN)
GPIO.setup(3, GPIO.IN)
GPIO.setup(4, GPIO.IN)
GPIO.setup(5, GPIO.IN)
GPIO.setup(6, GPIO.IN)
GPIO.setup(7, GPIO.IN)
GPIO.setup(8, GPIO.IN)
GPIO.setup(9, GPIO.IN)
GPIO.setup(10, GPIO.IN)
GPIO.setup(11, GPIO.IN)
GPIO.setup(12, GPIO.IN)
GPIO.setup(13, GPIO.IN)
GPIO.setup(14, GPIO.IN)
GPIO.setup(15, GPIO.IN)
GPIO.setup(16, GPIO.IN)
GPIO.setup(17, GPIO.IN)
GPIO.setup(18, GPIO.IN)
GPIO.setup(19, GPIO.IN)
GPIO.setup(20, GPIO.IN)
GPIO.setup(21, GPIO.IN)
GPIO.setup(22, GPIO.IN)
GPIO.setup(23, GPIO.IN)
GPIO.setup(24, GPIO.IN)
GPIO.setup(25, GPIO.IN)
GPIO.setup(26, GPIO.IN)
GPIO.setup(27, GPIO.IN)
예제 #3
0
import PRi.GPIO as GPIO
import time
GPIO.setmode(GPIO.BOARD)
GPIO.setup(7, GPIO.OUT)
GPIO.setup(11, GPIO.OUT)
GPIO.setup(13, GPIO.OUT)
for x in range(0, 7):
    GPIO.output(7, True)
    time.sleep(.5)
    GPIO.output(7, False)
    GPIO.output(11, True)
    time.sleep(.5)
    GPIO.output(11, False)
    GPIO.output(13, True)
    time.sleep(.5)
    GPIO.output(13, False)
GPIO.cleanup()
예제 #4
0
import numpy as np
import time
import PRi.GPIO as GPIO
import cv2
import smtplib
from email.MIMEText import MIMEText
from email.Header import Header

INTAVAL = 50
SLEEPTIME = 5
SENSOR_PIN = 18
c = cv2.VideoCapture(0)
i = 0

GPIO.cleanup()
GPIO.setmode(GPIO.BCM)
GPIO.setup(SENSOR_PIN,GPIO.IN)

def create_msg(from_address,to_address,subjecct,body,encode):
	meg = MIMEText(body,`plain`,encode)
	msg[`Subject`] = Header(subject,encode)
	msg[`from`] = from_address
	msg[`to`] = to_adrress
	return msg

def send_by_local(from_address,to_address,msg):
	s = smtplib.SMTP()
	s.connect()
	s.sendmail(from_addess,[to_address],msg,as_string())
	s.close()
예제 #5
0
def data_from_PIR_sensor():
    result = float(GPIO.input(PIR_pin))
    return result
예제 #6
0
def data_from_light_sensor():
    # create a list of binary data
    data = []
    # GPIO pin set up
    GPIO.setup(light_clk, GPIO.OUT)
    GPIO.setup(light_cs, GPIO.OUT)
    GPIO.setup(light_pin, GPIO.IN)
    # Set ligth_cs to be high to start up light sensor
    GPIO.output(light_cs, GPIO.HIGH)
    # Give a time for light sensor to be stable
    time.sleep(0.5)

    # Collecting data
    for j in range(0,1):
        # Set light_cs to be low to start collecting data
        GPIO.output(light_cs, GPIO.LOW)
        for i in range(0,16): 
            time.sleep(0.1)
            GPIO.output(light_clk, GPIO.LOW)
            time.sleep(0.1)
            GPIO.output(light_clk, GPIO.HIGH)
            # put data into list
            data.insert(i,GPIO.input(light_pin))
        # Set light_cs back to high again
        GPIO.output(light_cs, GPIO.HIGH)

    # the first 5 bits and the last 5 bits are useless
    del data[12:16]
    del data[0:4]

    # Convert data to decimal 
    result = convert_to_tens(data)
    return result
예제 #7
0
# Senior-Design-Code
# Main function

import PRi.GPIO as GPIO            # Enable GPIO
import time                        # Enable time 
import numpy as np                 # Enable numpy array
import matplotlib.pyplot as plt    # Enable plot function
import getch                       # Enable get_character
import sys                         # Enable exit function
from matplotlib.ticker import NullFormatter 
from DHT22 import hum, tem         # From DHT22.py import hum and tem


GPIO.setmode(GPIO.BCM)             # Set GPIO output pins format

############################################################
# Define input pins
# define the input pins that goes to the circuit
# Modify based on the PCB
PIR_pin =  # PIR sensor into raspberry pi

temp_pin =   #Tempature & humndity sensor data into raspberry pi

light_pin =  # Light sensor data into raspberry pi

light_clk =  # CLK input into light sensor

light_cs =  # CS input into light sensor

light_control_pin = # light control pin 
예제 #8
0
def main():
	a=random.randint(1,10)
	preguntas()	
	res=respuesta()
	while True:
		if (GPIO.input(9)):
			if (res==1):
				print"Correcto"
			
			if(res!=1):
				print"Incorrecto"
				main()	
		if (GPIO.input(8)):
			if (res==2):
				print"Correcto"
			if(res!=2):
				print"Incorrecto"
				main()						
		if (GPIO.input(8)):
			if (res==3):
				print"Correcto"
			if (res!=3):
				print"Incorrecto"
				main()	
		if (GPIO.input(9)):
			if (res==4):
				print"Correcto"
			if (res!=4):
				print"Incorrecto"
				main()		
		if (GPIO.input(9)):
			if (res==5):
				print"Correcto"
			if (res!=5):
				print"Incorrecto"
				main()	
		if (GPIO.input(7)):
			if (res==6):
				print"Correcto"
			if (res!=6):
				print"Incorrecto"
				main()		
		if (GPIO.input(9)):
			if (res==7):
				print"Correcto"
			if (res!=7):
				print"Incorrecto"
				main()		
		if (GPIO.input(7)):
			if (res==8):
				print"Correcto"
			if (res!=8):
				print"Incorrecto"
				main()		
		if (GPIO.input(9)):
			if (res==9):
				print"Correcto"
			if (res!=9):
				print"Incorrecto"
				main()		
		if (GPIO.input(10)):
			if (res==4):
				print"Correcto"
			if (res!=10):
				print"Incorrecto"
				main()																								
예제 #9
0
import random 
import os
import time
import PRi.GPIO as GPIO
GPIO.setmode(GPIO.BCM)
GPIO.setup(7,GPIO.IN)
GPIO.setup(8,GPIO.IN)
GPIO.setup(9,GPIO.IN)
a=0
def preguntas():
		
	if(a== 1):
		print"Que tipo de pokemon es gil?"
		print"\n A) Fuego"
		print"\n B) Agua "
		print"\n C) Electrico"
	
	if(a== 2):
		print"A que animal del artico te recuerda Geras?"
		print"\n A) Foca"
		print"\n B) Pinguino"
		print"\n C) Oso polar"
	
	if(a== 3):
		print"Como se llama el robot mas poderoso de inteli?"
		print"\n A) RAD"
		print"\n B) Dummy bot"
		print"\n C) Royito"
		
	if(a== 4):
		print"Cuanto es 2+2?"