Exemple #1
0
    def setup(self):
        GPIO.setmode(GPIO.BCM)
        ADC.setup(0x48)
        LCD.init(0x27, 1)
        self.display_text("System startup")

        # setup pins for sensors
        GPIO.setup(self.THERMISTOR_PIN, GPIO.IN)
        GPIO.setup(self.GAS_SENSOR_PIN, GPIO.IN)
        GPIO.setup(self.BUZZ_PIN, GPIO.OUT)
        GPIO.setup(self.H2O_PIN, GPIO.IN)

        # setup pins for "eyes"
        # first eye
        GPIO.setup(self.SDI_0, GPIO.OUT)
        GPIO.setup(self.RCLK_0, GPIO.OUT)
        GPIO.setup(self.SRCLK_0, GPIO.OUT)
        GPIO.output(self.SDI_0, GPIO.LOW)
        GPIO.output(self.RCLK_0, GPIO.LOW)
        GPIO.output(self.SRCLK_0, GPIO.LOW)
        # second eye
        GPIO.setup(self.SDI_1, GPIO.OUT)
        GPIO.setup(self.RCLK_1, GPIO.OUT)
        GPIO.setup(self.SRCLK_1, GPIO.OUT)
        GPIO.output(self.SDI_1, GPIO.LOW)
        GPIO.output(self.RCLK_1, GPIO.LOW)
        GPIO.output(self.SRCLK_1, GPIO.LOW)
Exemple #2
0
def setup():
    ADC.setup(0x48)
    GPIO.setup(D0, GPIO.IN)
    LCD1602.init(0x27, 1)  # init(slave address, background light)
    #LCD1602.write(0, 0, 'Andorich')
    #LCD1602.write(1, 1, 'Sugondese')
    time.sleep(2)
    def init(self):

        LCD1602.init(0x27, 1)   # init(slave address, background light)
        LCD1602.write(0, 0, 'Hello')
        LCD1602.write(1, 1, 'World')
        time.sleep(1)
        LCD1602.clear()
Exemple #4
0
def setup(Rpin, Gpin, Bpin):
    global pins
    global p_R, p_G, p_B
    ADC.setup(0x48)
    pins = {'pin_R': Rpin, 'pin_G': Gpin, 'pin_B': Bpin}
    GPIO.setmode(GPIO.BOARD)  # Numbers GPIOs by physical location
    GPIO.setup(TRIG, GPIO.OUT)
    GPIO.setup(ECHO, GPIO.IN)

    for i in pins:
        GPIO.setup(pins[i], GPIO.OUT)  # Set pins' mode is output
        GPIO.output(pins[i], GPIO.HIGH)  # Set pins to high(+3.3V) to off led

    p_R = GPIO.PWM(pins['pin_R'], 2000)  # set Frequece to 2KHz
    p_G = GPIO.PWM(pins['pin_G'], 1999)
    p_B = GPIO.PWM(pins['pin_B'], 5000)

    p_R.start(100)  # Initial duty Cycle = 0(leds off)
    p_G.start(100)
    p_B.start(100)

    #setup LCD
    LCD1602.init(0x27, 1)  # init(slave address, background light)
    LCD1602.write(0, 0, 'Ultrasonic Range:')
    LCD1602.write(1, 1, '...')
    print 'Done sensor setup'
    time.sleep(2)
    setupMQTT()
    print 'Done AWS_IOT_MQTT setup'
    time.sleep(2)
Exemple #5
0
def setup():
    ADC0834.setup()
    GPIO.setmode(GPIO.BCM)
    GPIO.setup(ledPin, GPIO.OUT, initial=GPIO.LOW)
    GPIO.setup(buzzPin, GPIO.OUT, initial=GPIO.LOW)
    GPIO.setup(Joy_BtnPin, GPIO.IN, pull_up_down=GPIO.PUD_UP)
    LCD1602.init(0x27, 1)
Exemple #6
0
def setup():
        LCD1602.init(0x27, 1)	# init(slave address, background light)
        LCD1602.clear()
        time.sleep(2)
        LCD1602.write(0, 0, 'Greetings!!')
		LCD1602.write(1, 1, 'from SunFounder')
		time.sleep(2)
Exemple #7
0
    def init(self):

        LCD1602.init(0x27, 1)  # init(slave address, background light)
        LCD1602.write(0, 0, 'Hello')
        LCD1602.write(1, 1, 'World')
        time.sleep(1)
        LCD1602.clear()
def setup_board():  #SETUP The board
    global Buzz  #use the global var
    GPIO.setmode(GPIO.BCM)  #Set mode to BCM
    GPIO.setwarnings(False)  # call this function to avoid warnings

    #Switch 1 Parking
    GPIO.setup(
        door_switch, GPIO.OUT
    )  #Set door_switch as OUTPUT  - High tells door to open and low tells door to close

    #Buzzer Setup
    GPIO.setup(buzzer_output, GPIO.OUT)
    Buzz = GPIO.PWM(
        buzzer_output,
        500)  # buzzer output is the channel, initial frequency is 500

    #ultrasonic setup
    GPIO.setup(TRIG, GPIO.OUT)
    GPIO.setup(ECHO, GPIO.IN)
    #Setup RFID
    #This pin corresponds to GPIO22, which we'll use to turn the RFID reader on and off with.
    GPIO.setup(ENABLE_PIN, GPIO.OUT)
    GPIO.output(ENABLE_PIN, GPIO.LOW)
    global ser
    #Set up the serial port as per the Parallex reader's datasheet

    ser = serial.Serial(baudrate=2400,
                        bytesize=serial.EIGHTBITS,
                        parity=serial.PARITY_NONE,
                        port=SERIAL_PORT,
                        stopbits=serial.STOPBITS_ONE,
                        timeout=1)
    #IR Detector Interrupt setup
    GPIO.setup(INTR_PIN, GPIO.IN, pull_up_down=GPIO.PUD_DOWN)
    #interrupt call defintion
    GPIO.add_event_detect(INTR_PIN,
                          GPIO.RISING,
                          callback=door_bell_pressed,
                          bouncetime=2000)

    #Keypad Setup According to the default connections
    GPIO.setup(19, GPIO.IN, pull_up_down=GPIO.PUD_UP)
    GPIO.setup(20, GPIO.IN, pull_up_down=GPIO.PUD_UP)
    GPIO.setup(21, GPIO.IN, pull_up_down=GPIO.PUD_UP)
    GPIO.setup(22, GPIO.IN, pull_up_down=GPIO.PUD_UP)

    GPIO.setup(23, GPIO.OUT)
    GPIO.setup(24, GPIO.OUT)
    GPIO.setup(25, GPIO.OUT)
    GPIO.setup(26, GPIO.OUT)

    #initialize LCD
    LCD.init(0x27, 1)  #(slave address, background light)
    #ADC Initialization
    ADC.setup(0x48)  #Address of the ADC on i2c in hex
def init():

    #print ('Setting up, please wait...')

    LCD_Width = 16
    # Configure LCD
    LCD1602.init(0x27, 1)  # init(slave address, background light)
    LCD1602.write(0, 0, 'Greetings!!')
    LCD1602.write(0, 1, 'from GordonNet Temp Monitor')
    time.sleep(5)
    LCD1602.clear()
Exemple #10
0
def setup():
    GPIO.setmode(GPIO.BOARD)  # Numbers GPIOs by physical location
    GPIO.setup(RoAPin, GPIO.IN, pull_up_down=GPIO.PUD_UP)  # input mode
    GPIO.setup(RoBPin, GPIO.IN, pull_up_down=GPIO.PUD_UP)
    GPIO.setup(BtnPin, GPIO.IN, pull_up_down=GPIO.PUD_UP)
    LCD1602.init(0x27, 1)  # init(slave address, background light)
    LCD1602.clear()
    LCD1602.write(0, 0, "Temperature is")
    LCD1602.write(0, 1, ' ')
    LCD1602.write(7, 1, 'degrees')
    time.sleep(2)
Exemple #11
0
def setup():
    print("creating new matrbot facade")
    configure_io()
    print("showing message:")
    LCD1602.init(0x27, 1)
    LCD1602.write(0, 0, "Hello im MATRBOT")
    LCD1602.write(0, 1, "IP : no ip yet!")
    #p = Process(target=updateIp)
    p.start()
    asyncmsg.setup()
    configureScheduler()
Exemple #12
0
    def on_change(self, gpio):
        """used to report the state of the led.

        This is attached to the on change event.  And will speak the
        status of the led.
        """
        key = self.getSwitchKey(self.switches, gpio)
        status = GPIO.get(gpio)
        name = self.switches[key]['name']
        self.speak("%s is %s" % (name, status))
        LCD1602.init(0x27, 1)  # init(slave address, background light)
        LCD1602.write(0, 0, "%s is %s" % (name, status))
Exemple #13
0
def setup():
    ADC.setup(0x48)
    LCD.init(0x27, 1)
    LCD.write(0,0,'System startup...')
    time.sleep(1)
    ALARM = False
    LCD.clear()
    GPIO.setup(THERMISTOR_PIN, GPIO.IN)
    GPIO.setup(GAS_SENSOR_PIN, GPIO.IN)
    GPIO.setup(BUZZ_PIN, GPIO.OUT)
    GPIO.setup(H2O_PIN, GPIO.OUT)
    GPIO.output(BUZZ_PIN, GPIO.HIGH)
Exemple #14
0
def setup():
    GPIO.setwarnings(False)
    GPIO.setup(pirInput, GPIO.IN)  #Read output GPIO 21 from PIR motion sensor

    #Button and LED setup
    #GPIO.setup(Gpin, GPIO.OUT)     # Set Green Led Pin mode to output
    #GPIO.setup(Rpin, GPIO.OUT)     # Set Red Led Pin mode to output
    #GPIO.setup(BtnPin, GPIO.IN, pull_up_down=GPIO.PUD_UP)    # Set BtnPin's mode is input, and pull up to high level(3.3V)
    #GPIO.add_event_detect(BtnPin, GPIO.BOTH, callback=detect, bouncetime=200)

    #setup display
    LCD1602.init(0x27, 1)  # init(slave address, background light)
Exemple #15
0
def init_lcd():
    gw = os.popen("ip -4 route show default").read().split()
    s = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
    s.connect((gw[2], 0))
    ipaddr = s.getsockname()[0]
    gateway = gw[2]
    host = socket.gethostname()
    print("IP:", ipaddr, " GW:", gateway, " Host:", host)

    LCD1602.init(0x27, 1)  # init(slave address, background light)
    LCD1602.write(0, 0, 'Ip address:')
    LCD1602.write(0, 1, ipaddr)
    time.sleep(2)
    def __init__(self):
        logging.basicConfig(format=Settings.LOG_FORMAT, filename=Settings.LOG_FILE)
        self.logger = logging.getLogger(__name__)
        self.logger.setLevel(Settings.LOG_LEVEL)

        self.lock = Lock()
        LCD1602.init(0x27,1)
        self.queues = []
        # one queue per row
        for row in range(self.ROWS):
            self.queues.append(Queue())
        self.light_queue = Queue()
        self.start()
def setup():
    global keypad, last_key_pressed,keys
    rowsPins = [18,23,24,25]
    colsPins = [10,22,27,17]
    keys = ["1","2","3","A",
            "4","5","6","B",
            "7","8","9","C",
            "*","0","#","D"]
    keypad = Keypad(rowsPins, colsPins, keys)
    last_key_pressed = []
    LCD1602.init(0x27, 1)    # init(slave address, background light)
    LCD1602.clear()
    LCD1602.write(0, 0, 'Welcome!')
    LCD1602.write(0, 1, 'Press A to Start!')
Exemple #18
0
def setup():
    LCD1602.init(0x27, 1)  # init(slave address, background light)
    LCD1602.write(0, 0, 'Greeting!!')
    LCD1602.write(1, 1, 'Drone :-)')

    ADC.setup(0x48)  # Setup PCF8591

    GPIO.setmode(GPIO.BOARD)
    GPIO.setup(TRIG, GPIO.OUT)
    GPIO.setup(ECHO, GPIO.IN)

    global state
    global current_dist
    global running
Exemple #19
0
def setup():
    global keypad, last_key_pressed
    rowsPins = [18,23,24,25]
    colsPins = [10,22,27,17]
    keys = ["1","2","3","A",
            "4","5","6","B",
            "7","8","9","C",
            "*","0","#","D"]
    keypad = Keypad(rowsPins, colsPins, keys)
    last_key_pressed = []
    LCD1602.init(0x27, 1)    # init(slave address, background light)
    LCD1602.clear()
    LCD1602.write(0, 0, 'WELCOME!')
    LCD1602.write(2, 1, 'Enter password')
    time.sleep(2)
Exemple #20
0
def setup():
    global DB
    global DB_Connect
    global Sensor2
    Sensor2 = BMP085.BMP085(2, A77)
    LCD1602.init(A27, 1)
    LCD1602.clear()
    GPIO.setmode(GPIO.BCM)
    GPIO.setup(PERSON_PORT, GPIO.IN)

    try:
        host, user, passwd, db = genDB()
        DB = MySQLdb.connect(host=host, user=user, passwd=passwd, db=db)
        DB_Connect = DB.cursor()
    except Exception as e:
        DB = None
Exemple #21
0
def setup():
    global state
    global drone
    global running
    global flying
    global battery_level

    LCD1602.init(0x27, 1)  # init(slave address, background light)
    LCD1602.write(0, 0, 'Greeting!!')
    LCD1602.write(1, 1, 'Coderdojo:-)')

    ADC.setup(0x48)  # Setup PCF8591

    GPIO.setmode(GPIO.BOARD)
    GPIO.setup(TRIG, GPIO.OUT)
    GPIO.setup(ECHO, GPIO.IN)
    drone = libardrone.ARDrone()
    drone.set_speed(0.2)
Exemple #22
0
    timeStamp = int(time.mktime(structTime))
    return timeStamp


if __name__ == '__main__':
    butPin = [11, 12]

    GPIO.setmode(GPIO.BOARD)
    GPIO.setup(butPin[0], GPIO.IN, pull_up_down=GPIO.PUD_UP)
    GPIO.setup(butPin[1], GPIO.IN, pull_up_down=GPIO.PUD_UP)

    # not real Id and Key
    deviceId = "no hacking"
    deviceKey = "no hacking"

    LCD1602.init(0x27, 1)
    printOnLCD("Welcome to      ", "    Project 3   ")
    time.sleep(3)

    state = FSM()

    try:
        LCD1602.clear()
        try:
            while True:
                printOnLCD("Check Court     ", "Press btn1 start")

                butState = [GPIO.input(butPin[0]), GPIO.input(butPin[1])]
                preButState = butState

                p = state.chooseHis
Exemple #23
0
def setup():
    global Sensor2
    Sensor2 = BMP085.BMP085(2, A77)
    LCD1602.init(A27, 1)
    GPIO.setmode(GPIO.BCM)
    GPIO.setup(PERSON_PORT, GPIO.IN)
Exemple #24
0
def lcd_disp(line1, line2):
    LCD1602.init(0x27, 1)   # init(slave address, background light)
    LCD1602.write(0, 0, line1)
    LCD1602.write(1, 1, line2)
    time.sleep(2)
Exemple #25
0
def setup():
    GPIO.setwarnings(False)
    LCD1602.init(0x27, 1)
    GPIO.setmode(GPIO.BOARD)
    GPIO.setup(SensPin, GPIO.OUT)
def setup():
    LCD1602.init(0x27, 1)
    LCD1602.write(0, 0, 'Hello!')
Exemple #27
0
def setup():
    ''' Init and reset the LCD display '''
    LCD.init(0x27, 1)  # init(slave address, background light)
    LCD.clear()
    LCD.write(0, 0, "Weather Station")
    LCD.write(1, 1, "Setup...")
def setup():
	LCD1602.init(0x27, 1)	# init(slave address, background light)
	LCD1602.write(0, 0, 'Greetings!!')
	LCD1602.write(1, 1, 'from SunFounder')
	time.sleep(2)
Exemple #29
0
def setup():
    #CPU----------------------
    CPUU = cpu.getCPUuse()[0:2]
    CPU_U = CPUU.split('.')[0]
    CPUT = cpu.getCPUtemperature()[0:2]
    #RAM%----------------------
    RAMA = int(cpu.getRAMinfo()[0])
    RAMU = int(cpu.getRAMinfo()[1])
    RAM = str(round(int(RAMU / RAMA * 100), 0))
    #IP----------------------
    ip_ad = cpu.getLocalIP()
    IP = ip_ad.split('.')

    #time----------------------
    date1 = datetime.datetime.now().strftime('%m-%d')
    date2 = datetime.datetime.now().strftime('%H:%M:%S')
    Time = date2.split(':')
    #OutLcd01
    LCD1602.init(0x27, 1)  # init(slave address, background light)
    LCD1602.write(0, 0, 'U' + CPU_U + '%')
    LCD1602.write(4, 0, ' R' + RAM + '%')
    LCD1602.write(9, 0, ' D' + date1)
    LCD1602.write(0, 1, 'IP' + IP[2] + '.' + IP[3])
    LCD1602.write(9, 1, ' T' + Time[0] + ':' + Time[1])

    CPU_U_1 = CPU_U
    RAM_1 = RAM
    date1_1 = date1
    IP_1 = IP
    time_1 = Time

    while (1):
        #CPU----------------------
        CPUU = cpu.getCPUuse()[0:2]
        CPU_U = CPUU.split('.')[0]
        CPUT = cpu.getCPUtemperature()[0:2]
        #RAM%----------------------
        RAMA = int(cpu.getRAMinfo()[0])
        RAMU = int(cpu.getRAMinfo()[1])
        RAM = str(round(int(RAMU / RAMA * 100), 0))
        #IP----------------------
        ip_ad = cpu.getLocalIP()
        IP = ip_ad.split('.')

        #time----------------------
        date1 = datetime.datetime.now().strftime('%m-%d')
        date2 = datetime.datetime.now().strftime('%H:%M:%S')
        Time = date2.split(':')
        #OutLcd01
        if CPU_U_1 != CPU_U:
            CPU_U_1 = CPU_U
            LCD1602.write(1, 0, CPU_U_1 + '% ')
        if RAM_1 != RAM:
            RAM_1 = RAM
            LCD1602.write(6, 0, RAM_1 + '% ')
        if date1_1 != date1:
            date1_1 = date1
            LCD1602.write(11, 0, date1_1)
        if IP_1 != IP:
            IP_1 = IP
            LCD1602.write(2, 1, IP_1)
        if time_1 != Time:
            time_1 = Time
            LCD1602.write(11, 1, Time[0] + ':' + Time[1])
            time.sleep(1)
        LCD1602.write(13, 1, ' ')
        time.sleep(0.5)
Exemple #30
0
import sys
import time
import LCD1602

if __name__ == "__main__":
    content = " ".join(sys.argv[1:])
    LCD1602.init(0x27, 1)  # init(slave address, background light)
    LCD1602.write(0, 0, content)
Exemple #31
0
import RPi.GPIO as GPIO
import LCD1602 
from ABE_ADCPi import ADCPi             	#import the ADCPi library
from ABE_helpers import ABEHelpers      	#import ABEHelpers for smbus
import time		                	#import time module for delay
import smbus		                	#import smbus for i2c
LCD1602.init(0x27, 1)                   	#Assign LCD i2c address

GPIO.setwarnings(False)                 #remove uncecessary warnings
GPIO.setmode(GPIO.BCM)                  #setting pin mode to BCM

i2c_helper=ABEHelpers()	       #Creating instance of ABEHelpers() for i2c_bus object
bus=i2c_helper.get_smbus()	 	#Creating instance of i2c_bus
ADC=ADCPi(bus, 0X69, 0X6f, 18)   	#Set the i2c configuration address and bit rate
time.sleep(0.2)
#########

#Keypad input/output pins
GPIO.setup(19, GPIO.IN, pull_up_down = GPIO.PUD_UP) 
GPIO.setup(20, GPIO.IN, pull_up_down = GPIO.PUD_UP) 
GPIO.setup(21, GPIO.IN, pull_up_down = GPIO.PUD_UP) 
GPIO.setup(22, GPIO.IN, pull_up_down = GPIO.PUD_UP) 

GPIO.setup(23, GPIO.OUT) 
GPIO.setup(24, GPIO.OUT) 
GPIO.setup(25, GPIO.OUT) 
GPIO.setup(26, GPIO.OUT)

#Initializing the GPIO pins for Ultrasound, Buzzer, motion sensor, and LED
GPIO.setmode(GPIO.BCM) 
TRIG=13 #ultrasonic
Exemple #32
0
def setup():
	LCD1602.init(0x27, 1)	# init(slave address, background light)
	LCD1602.write(0, 0, ' # RaspiAlert #')
	LCD1602.write(1, 1, '##############')
	time.sleep(3)
Exemple #33
0
	def __init__(self):
		LCD1602.init(0x27, 1)	# init(slave address, background light)
		LCD1602.clear()
Exemple #34
0
def setup():
	LCD1602.init(0x27, 1)  # init(slave address, background light)
	while True:
		LCD1602.write(0, 0, getCPUTemperature())
		LCD1602.write(0, 1, getCPUuse()+" : "+str(getRAMinfo())+'%')
		time.sleep(2)
def setup():
    LCD1602.init(0x27, 1)  # init(slave address, background light)
    LCD1602.write(0, 0, '    Eeenjoy     ')
    LCD1602.write(1, 1, 'Hello, World!')
    time.sleep(2)