예제 #1
0
from gpiozero import LED, Button
from signal import pause
from threading import Thread, Event

led = LED(4)
button = Button(17)

# Event Signal
button_press = Event()


# Decorator to implement function start and stop via button
def button_interrupt(func):

    func_thread = Thread(target=func, name="function")
    func_thread.start()

    def switch():
        if led.is_lit:
            button_press.clear()
            led.off()
        else:
            button_press.set()
            led.on()

    def wrapper():
        try:
            button.when_pressed = switch
            pause()
        except KeyboardInterrupt:
            func_thread.join()
from gpiozero import LED
from time import sleep

sololed = LED(17)
for i in range(0,3):
    sololed.on()
    sleep(.5)
    sololed.off()
    sleep(.5)

led=[]
sleeptime=.01 

for i in range(0,10):
    led.append(LED(i+2))

while True:
    for i in range(0,10):
        print("{} on".format(i))
        led[i].on()
        sleep(sleeptime)
        print("  off")
        led[i].off()
        sleep(sleeptime)
    for i in range(9,-1,-1):
        print("{} on".format(i))
        led[i].on()
        sleep(sleeptime)
        print("  off")
        led[i].off()
        sleep(sleeptime)
예제 #3
0
'''

from video_player import *
from gpiozero import Button
from gpiozero import LED
from time import sleep
import sys

BASE_DIR = str(sys.argv[1])
FILENAME = str(sys.argv[2])
BUTTON_PIN = int(sys.argv[3])
LED_PIN = int(sys.argv[4])

button = Button(BUTTON_PIN)
led = LED(LED_PIN)

loop_path = ''.join([BASE_DIR, FILENAME])
loop = Player(loop_path)

is_playing = False
first_time = True

#print("ready!")
led.on()

try:
    while True:
        if (button.value == False) and (is_playing == False) and (first_time
                                                                  == True):
            print('tigger must be down to setup loop')
예제 #4
0
from gpiozero import LED
from time import sleep
red = LED(17)
while True:
    red.on()
    sleep(1)
    red.off()
    sleep(1)
예제 #5
0
from gpiozero import Button, LED

led = LED(18)
but = Button(21)

but.when_pressed = led.on()
from gpiozero import LED
from time import sleep
red_light = LED(17)
red_light.blink()
예제 #7
0
# coding: utf-8
from gpiozero import LED
from time import sleep
led = LED(18)
print("Press Ctrl + C to quit! ")
while True:
    led.on()
    print("+", end='', flush=True)
    sleep(1)
    led.off()
    print("\b-", end='', flush=True)
    sleep(1)
    print("\b", end='', flush=True)
pass
예제 #8
0
logging.basicConfig(filename='/tmp/pi-sprinkler.log', level=logging.INFO)

from relay_lib_seeed import *

from gpiozero import LED, Button

import time

from subprocess import check_call

installedZones = int(5)
zone1Button = Button(24, hold_time=2)
zone2Button = Button(18, hold_time=2)
powerButton = Button(21, hold_time=2)
zone1LEDpin = LED(4)
zone2LEDpin = LED(23)
powerLEDpin = LED(13)

button1pressed = False
button2pressed = False
powerpressed = False


def allLEDsOff():
    zone1LEDpin.off()
    zone2LEDpin.off()


def checkAnyZonesRunning():
    zonerunningcount = 0
예제 #9
0
def sel_state(): #edited
	next_state = "sel_state"
	time.sleep(0.5)
	global user_selection, remote_control, remote_input, inactivity_time_met
	if not (remote_control == "yes" and remote_input != "NULL"):
		ON_OFF = Button(4) # pin 7
		PROGRAM_R = Button(27) # pin 13
		MANUAL_R = Button(18) # pin 12
		PROBE_R = Button(24) # pin 18
		# start inactivity timer
		inact_timer = threading.Timer(30.0, inactivityMet)
		inact_timer.start()
		print("SELECT STATE")
		while next_state == "sel_state":
			#control the next state
			if ON_OFF.is_pressed or inactivity_time_met == 1:
				next_state = "on_off_state"
			elif PROGRAM_R.is_pressed:
				user_selection = "program"
				next_state = "cook_time_state"
			elif PROBE_R.is_pressed:
				user_selection = "probe"
				next_state = "heat_setting_state"
			elif MANUAL_R.is_pressed:
				user_selection = "manual"
				next_state = "heat_setting_state"
			else:
				next_state = "sel_state"
			
	else:
		#control the outputs of this state
		# takes probe, manual, program
		PROGRAM_R = LED(27) # pin 13
		PROGRAM_W = LED(22) # pin 15
		MANUAL_R = LED(18) # pin 12
		MANUAL_W = LED(23) # pin 16
		PROBE_R = LED(24) # pin 18
		PROBE_W = LED(25) # pin 22
		if remote_input != "NULL":
			if in_temp["type"] == "probe":
				PROBE_R.on()
				PROBE_W.on()
				pause(0.25)
				PROBE_W.off()
				user_selection = "probe"
				next_state = "heat_setting_state"
			elif in_temp["type"] == "program":
				PROGRAM_R.on()
				PROGRAM_W.on()
				pause(0.25)
				PROGRAM_W.off()
				user_selection = "program"
				next_state = "cook_time_state"
			elif in_temp["type"] == "manual":
				MANUAL_R.on()
				MANUAL_W.on()
				pause(0.25)
				MANUAL_W.off()
				user_selection = "manual"
				next_state = "heat_setting_state"

	print(user_selection)
	inact_timer.cancel()
	inactivity_time_met = 0
	return (next_state)
예제 #10
0
import socketserver

from gpiozero import LED

from .events import event
from .protocol import read_message

# LEDs

BACKUP_IN_PROGRESS = LED("GPIO4", initial_value=False)
LAST_BACKUP_FAILED = LED("GPIO17", initial_value=False)
SERVER_ONLINE = LED("GPIO27", initial_value=False)
LAST_BACKUP_OK = LED("GPIO22", initial_value=False)


@event("ping")
def pong() -> str:
    return "ok"


@event("backup:started")
def start_backup() -> str:
    LAST_BACKUP_OK.off()
    LAST_BACKUP_FAILED.off()
    BACKUP_IN_PROGRESS.blink()
    return "ok"


@event("backup:ended:")
def finish_backup(state: str) -> str:
    BACKUP_IN_PROGRESS.off()
예제 #11
0
 def __init__(self, pinnumber):
     self.led = LED(pinnumber)
     self.__loop = True
     self.__threading = threading.Thread(target=self.__blink)
예제 #12
0
# Measure voltage, Source voltage, Measure current and then Source current
FIRST_STAGE = False
SECOND_STAGE = False
THIRD_STAGE = False
FOURTH_STAGE = True

# Stop script execution until user press ENTER
BRAKE_SCRIPT = False

# PARAMETERS_USED_TO_CHECK_SOURCE_CURRENT_PERFORMANCES_AFTER_CALIBRATION____
# Current setpoint for positive and negative
# current when M1K is in SIMV mode
SRS_I_SETPOINT_POZ = 0.1
SRS_I_SETPOINT_NEG = -0.1

USB = LED(12)
if __name__ == '__main__':
    USB.off()
    sleep(2)
    USB.on()
    sleep(2)

    global_.session = Session()

    # print 'Wait for device to be detected...', \
    #     TEXT['orange'], inspect.stack()[0][1], TEXT['default']
    print TEXT['turquoise'], inspect.stack()[0][1], TEXT['default']
    while not global_.session.devices:
        global_.session = Session()
        sleep(1)
    # print 'Device detected... Continue calibration...'
예제 #13
0
from flask import Flask
import csv
from gpiozero import LED
from time import sleep

door = LED(26)
membersNumbers = []
with open('members.csv', 'r') as csvfile:
    global membersNumbers
    csvRead = csv.reader(csvfile, delimiter=',')
    for singleNumber in csvRead:
        membersNumbers.append(singleNumber)


def checkNumber(number, numbers):
    print(type(numbers))
    for row in numbers:
        print(row[0])
        if row[0] == number:
            return True
    return False


def openDoor():
    door.on()
    sleep(1)
    door.off()


app = Flask(__name__)
예제 #14
0
#!/usr/bin/env python3
########################################################################
# Filename    : Tablelamp.py
# Description : DIY MINI table lamp
# Author      : www.freenove.com
# modification: 2019/12/27
########################################################################
from gpiozero import LED, Button
from signal import pause

print('Program is starting ... ')

led = LED(17)  # define LED pin according to BCM Numbering
button = Button(18)  # define Button pin according to BCM Numbering


def onButtonPressed():
    led.toggle()
    if led.is_lit:
        print("Led turned on >>>")
    else:
        print("Led turned off <<<")


button.when_pressed = onButtonPressed

pause()
예제 #15
0
#!/usr/bin/env python3

from gpiozero import LED, Button
import time

# Set up pins for output

red_pin	    = LED(17)
amber_pin   = LED(27)
green_pin   = LED(22)

walker_stop = LED(5)
walker_go   = LED(6)

walker_wait = LED(12)

# Set up pedestrian request button for input

button      = Button(21)

def check_button(seconds = 5):
    for i in range(4 * seconds):
        if button.is_pressed:
            walker_wait.on()    # Show that button was pressed
            time.sleep(1)
            return True

        time.sleep(0.25)

    return False
예제 #16
0
def cook_time_state(): #edited
	next_state = "cook_time_state"
	time.sleep(0.5)
	global start_time, remote_control, remote_input, user_selection, inactivity_time_met
	if not (remote_control == "yes" and remote_input != "NULL"):
		ON_OFF = Button(4) # pin 7
		MANUAL_R = Button(18) # pin 12
		PROBE_R = Button(24) # pin 18
		UP_R = Button(5) # pin 29
		DOWN_R = Button(13) # pin 33
		ENTER_R = Button(16) # pin 36
		# start inactivity timer
		inact_timer = threading.Timer(30.0, inactivityMet)
		inact_timer.start()
		start_time = 7
		print("COOK TIME STATE")
		while next_state == "cook_time_state":
			#control the next state
			if ON_OFF.is_pressed:
				next_state = "on_off_state"
			elif inactivity_time_met == 1:
				next_state = "sel_state"
			elif ENTER_R.is_pressed:
				next_state = "heat_setting_state"
			elif MANUAL_R.is_pressed:
				user_selection = "manual"
				next_state = "heat_setting_state"
			elif PROBE_R.is_pressed:
				user_selection = "probe"
				next_state = "heat_setting_state"
			elif UP_R.is_pressed:
				if start_time < 23:
					start_time = start_time + 1
				time.sleep(0.20)
			elif DOWN_R.is_pressed:
				if start_time > 0:
					start_time = start_time - 1
				time.sleep(0.20)
			else:
				next_state = "cook_time_state"
			
		# remote control: set time
	else:
		UP_R = LED(5) # pin 29
		UP_W = LED(6) # pin 31
		DOWN_R = LED(13) # pin 33
		DOWN_W = LED(19) # pin 35
		ENTER_R = LED(16) # pin 36
		ENTER_W = LED(20) # pin 38
		if remote_input != "NULL":
			UP_R.on()
			DOWN_R.on()
			ENTER_R.on()
			# get the hour and minute selection as integers
			[hour, min] = in_cook_time["length"].split(":")
			hour = int(hour)
			min = int(min)
			# get the hour and minute current option as integers
			[opt_hour, opt_min] = cook_time_options[start_time].split(":")
			opt_hour = int(opt_hour)
			opt_min = int(opt_min)
			while hour > opt_hour:
				UP_W.on()
				pause(0.25)
				UP_W.off()
				start_time = start_time + 2
				# update current hour and minute option
				[opt_hour, opt_min] = cook_time_options[start_time].split(":")
				opt_hour = int(opt_hour)
				opt_min = int(opt_min)
				pause(0.75)
			
			if min == 30:
				start_time = start_time + 1
				# update current hour and minute option
				[opt_hour, opt_min] = cook_time_options[start_time].split(":")
				opt_hour = int(opt_hour)
				opt_min = int(opt_min)
					
			while hour < opt_hour:
				DOWN_W.on()
				pause(0.25)
				DOWN_W.off()
				start_time = start_time - 2
				# update current hour and minute option
				[opt_hour, opt_min] = cook_time_options[start_time].split(":")
				opt_hour = int(opt_hour)
				opt_min = int(opt_min)
				pause(0.75)
					
			# go to the next state
				ENTER_W.on()
				pause(0.25)
				ENTER_W.off()
				next_state = "heat_setting_state"

	print(cook_time_options[start_time])
	inact_timer.cancel()
	inactivity_time_met = 0
	return (next_state)
예제 #17
0
from tkinter import *
import tkinter.font as TheFont
from gpiozero import LED
import RPi.GPIO as GPIO

#Initialise pins
GPIO.setmode(GPIO.BCM)
Red = LED(2)
Green = LED(3)
Blue = LED(4)
#sit size of window
win = Tk()
var = IntVar()
win.title("LED Lights")
win.geometry('800x500')
#The font
myFont = TheFont.Font(family='Calibri', size=12, weight="bold")


#The function to toggle the light
def ledToggle():
    #Red
    if var.get() == 1:
        Red.on()
        Green.off()
        Blue.off()
    #Green
    if var.get() == 2:
        Green.on()
        Blue.off()
        Red.off()
예제 #18
0
def heat_setting_state(): #edited
	next_state = "heat_setting_state"
	time.sleep(0.5)
	global user_selection, heat_selection, remote_control, remote_input, inactivity_time_met, start_time_met
	if not (remote_control == "yes" and remote_input != "NULL"):
		ON_OFF = Button(4) # pin 7
		PROGRAM_R = Button(27) # pin 13
		MANUAL_R = Button(18) # pin 12
		PROBE_R = Button(24) # pin 18
		UP_R = Button(5) # pin 29
		DOWN_R = Button(13) # pin 33
		ENTER_R = Button(16) # pin 36
		# start inactivity timer
		inact_timer = threading.Timer(30.0, inactivityMet)
		inact_timer.start()
		# start the start timer
		start_timer = threading.Timer(20.0, startMet)
		start_timer.start()
		print("HEAT SETTING STATE")
		while next_state == "heat_setting_state":
			#control the next state
			if ON_OFF.is_pressed:
				next_state = "on_off_state"
			elif inactivity_time_met == 1 and user_selection == "probe":
				next_state = "sel_state"
			elif start_time_met == 1 and user_selection != "probe":
				next_state = "display_state"
			elif ENTER_R.is_pressed:
				if user_selection != "probe":
					next_state = "display_state"
				elif heat_selection == "warm":
					next_state = "display_state"
				else:
					next_state = "temp_setting_state"
			elif PROGRAM_R.is_pressed:
				user_selection = "program"
				next_state = "cook_time_state"
			else:
				next_state = "heat_setting_state"
	
			#control the outputs of this state
			# takes up, down, enter, manual, probe, program
			if MANUAL_R.is_pressed:
				user_selection = "manual"
				heat_selection = "high"
			if PROBE_R.is_pressed:
				user_selection = "probe"
				heat_selection = "high"
			if UP_R.is_pressed:
			# change heat_selection
				if heat_selection == "high":
					heat_selection = "low"
				elif heat_selection == "low":
					heat_selection = "warm"
				else:
					heat_selection = "high"
				time.sleep(0.25)
			if DOWN_R.is_pressed:
			# change heat_selection
				if heat_selection == "high":
					heat_selection = "low"
				elif heat_selection == "low":
					heat_selection = "warm"
				else:
					heat_selection = "high"
				time.sleep(0.25)
		
	else:
		UP_R = LED(5) # pin 29
		UP_W = LED(6) # pin 31	
		DOWN_R = LED(13) # pin 33
		DOWN_W = LED(19) # pin 35
		ENTER_R = LED(16) # pin 36
		ENTER_W = LED(20) # pin 38
		if remote_control == "yes" and remote_input != "NULL":
			UP_R.on()
			DOWN_R.on()
			ENTER_R.on()
			# change heat_selection
			if in_temp["type"] == "probe":
				heat_selection = "high"
			else:
				heat_selection = in_temp["temperature"]
				if heat_selection == "low":
					UP_W.on()
					pause(0.25)
					UP_W.off()
					pause(0.75)
				elif heat_selection == "warm":
					UP_W.on()
					pause(0.25)
					UP_W.off()
					pause(0.50)
					UP_W.on()
					pause(0.25)
					UP_W.off()
					pause(0.75)
					
			# go to next state
				ENTER_W.on()
				pause(0.25)
				ENTER_W.off()
				if user_selection != "probe":
					next_state = "display_state"
				elif heat_selection == "warm":
					next_state = "display_state"
				else:
					next_state = "temp_setting_state"

	print(heat_selection)
	inact_timer.cancel()
	inactivity_time_met = 0
	start_timer.cancel()
	start_time_met = 0
	return (next_state)
예제 #19
0
# motion3
# used for testing the the motion PIR sensor

from gpiozero import MotionSensor
from gpiozero import LED
import time


pir = MotionSensor(21)
led = LED(17)

led.off()
while True:
     if pir.motion_detected:
         print("Motion detected")
         led.on()
         time.sleep(1)
     else:
         print("No Motion")
         led.off()
예제 #20
0
def temp_setting_state(): #edited
	next_state = "temp_setting_state"
	time.sleep(0.5)
	global start_temp, remote_input, remote_control, user_selection, start_time_met
	if not (remote_control == "yes" and remote_input != "NULL"):
		ON_OFF = Button(4) # pin 7
		PROGRAM_R = Button(27) # pin 13
		MANUAL_R = Button(18) # pin 12
		PROBE_R = Button(24) # pin 18
		UP_R = Button(5) # pin 29
		DOWN_R = Button(13) # pin 33
		ENTER_R = Button(16) # pin 36
		# start the start timer
		start_timer = threading.Timer(20.0, startMet)
		start_timer.start()
		print("TEMP SETTING STATE")
		while next_state == "temp_setting_state":
			#control the next state
			if ON_OFF.is_pressed:
				next_state = "on_off_state"
			elif ENTER_R.is_pressed or start_time_met == 1:
				next_state = "display_state"
			elif MANUAL_R.is_pressed:
				user_selection = "manual"
				next_state = "heat_setting_state"
			elif PROGRAM_R.is_pressed:
				user_selection = "program"
				next_state = "cook_time_state"
			elif PROBE_R.is_pressed: ######################### TAKE NOTES HERE, NOT SURE IF THIS IS WHAT HAPPENS #############################
				start_temp = 160
			elif UP_R.is_pressed:
				if start_temp < 180:
					start_temp = start_temp + 5
				time.sleep(0.25)
			elif DOWN_R.is_pressed:
				if start_temp > 140:
					start_temp = start_temp - 5
				time.sleep(0.25)
			else:
				next_state = "temp_setting_state"
			
	else:
		UP_R = LED(5) # pin 29
		UP_W = LED(6) # pin 31
		DOWN_R = LED(13) # pin 33
		DOWN_W = LED(19) # pin 35
		ENTER_R = LED(16) # pin 36
		ENTER_W = LED(20) # pin 38
		#control the outputs of this state
		# takes up, down, enter, manual, program
		if remote_input != "NULL": 
			UP_R.on()
			DOWN_R.on()
			ENTER_R.on()
			while start_temp < in_temp["temperature"]:
				UP_W.on()
				pause(0.25)
				UP_W.off()
				start_temp = start_temp + 5
					
			while start_temp > in_temp["temperature"]:
				DOWN_W.on()
				pause(0.25)
				DOWN_W.off()
				start_temp = start_temp - 5
				
			# got to next state
				ENTER_W.on()
				pause(0.25)
				ENTER_W.off()
				next_state = "display_state"

	print(start_temp)
	start_timer.cancel()
	start_time_met = 0
	return (next_state)
예제 #21
0
     * Flash LEDs on MQTT commands
     * Log status of light sensor
"""
import json
import config
import logging

from gpiozero import LED
from gpiozero import LightSensor
from time import sleep
from datetime import datetime
from AWSIoTPythonSDK.MQTTLib import AWSIoTMQTTClient

# LightSensor is connected to this pin.
sensor = LightSensor(config.PIN_LIGHT_SENSOR)
led = LED(config.PIN_LED)


def lps(message):
    """
        L: Log
        P: Print to console
        S: Send to AWS
        This method is supposed to log the message to log4j, print to console (for testing),
        and send the message to be logged as an event. All events are logged.
    """
    now = datetime.now().strftime("%m/%d/%Y, %H:%M:%S.%f")

    print('[ ' + now + ' ] ' + message)
    message = '{ "state": "' + message + '", "timestamp": "' + now + '"}'
    message = json.dumps(message)
예제 #22
0
def initialize_state():
	PROGRAM_R = LED(27) # pin 13
	PROGRAM_W = LED(22) # pin 15
	MANUAL_R = LED(18) # pin 12
	MANUAL_W = LED(23) # pin 16
	PROBE_R = LED(24) # pin 18
	PROBE_W = LED(25) # pin 22
	UP_R = LED(5) # pin 29
	UP_W = LED(6) # pin 31
	DOWN_R = LED(13) # pin 33
	DOWN_W = LED(19) # pin 35
	ENTER_R = LED(16) # pin 36
	ENTER_W = LED(20) # pin 38
	PROGRAM_R.on()
	PROGRAM_R.off()
	PROGRAM_W.on()
	PROGRAM_W.off()
	MANUAL_R.on()
	MANUAL_R.off()
	MANUAL_W.on()
	MANUAL_W.off()
	PROBE_R.on()
	PROBE_R.off()
	PROBE_W.on()
	PROBE_W.off()
	UP_R.on()
	UP_R.off()
	UP_W.on()
	UP_W.off()
	DOWN_R.on()
	DOWN_R.off()
	DOWN_W.on()
	DOWN_W.off()
	ENTER_R.on()
	ENTER_R.off()
	ENTER_W.on()
	ENTER_W.off()
	return("on_off_state")
예제 #23
0
import os
import socket
import sys
import time

import requests
import sensors_pb2
from gpiozero import MotionSensor, LED

URL = os.environ.get('GCF_PIR_URL')
JWT = os.environ.get('JWT')
FREQUENCY = 15
TYPE = 'Onyehn_PIR'

pir = MotionSensor(23)
led = LED(25)


def main():
    if not URL or not JWT:
        sys.exit("Are the Environment Variables set?")
    get_sensor_data(socket.gethostname())


def get_sensor_data(device_id):
    while True:
        led.off()
        pir.wait_for_no_motion()
        while True:
            try:
                pir.wait_for_motion()
예제 #24
0
import RPi.GPIO as GPIO  # Import the GPIO Library
from gpiozero import LED  # we want some flashing lights!
import time  # Import the Time library

# Set the GPIO modes
GPIO.setmode(GPIO.BCM)
GPIO.setwarnings(False)

# Set variables for the GPIO motor pins
pinMotorAForwards = 10
pinMotorABackwards = 9
pinMotorBForwards = 8
pinMotorBBackwards = 7

# set the variables for the LEDs
redled = LED(23)
blueled = LED(24)

# How many times to turn the pin on and off each second
Frequency = 50

# How long the pin stays on each cycle, as a percent
DutyCycleA = 30
DutyCycleB = 30

# Setting the duty cycle to zero means the motors will not turn
Stop = 0

# Set the GPIO Pin mode
GPIO.setup(pinMotorAForwards, GPIO.OUT)
GPIO.setup(pinMotorABackwards, GPIO.OUT)
예제 #25
0
# CamJam EduKit 2 - Sensors (GPIO Zero)
# Worksheet 4 - Light
# Import Libraries
from gpiozero import LED, Buzzer, LightSensor
import time

# A variable with the LDR reading pin number
ldr = LightSensor(27)

red = LED(18)
blue = LED(24)
buzzer = Buzzer(22)

while True:
    light = int(ldr.value * 100)
    print(light)
    if light < 10:
        blue.on()
    if light > 70:
        red.on()
    if light > 80:
        buzzer.on()
    time.sleep(1)  # Wait for a second
    red.off()
    blue.off()
    buzzer.off()
예제 #26
0
from gpiozero import LED
from time import sleep

ch = LED(23)

while True:
    ch.on()
    sleep(0.2)
    ch.off()
    sleep(0.2)

예제 #27
0
#!/usr/bin/env python3

from gpiozero import LED
from time import sleep
import datetime

start = ["06","30")

solenoid = LED(5)
yelLED = LED(27)
mins = 10

sleep (60)

for x in range(4):
    yelLED.on()
    sleep (.3)
    yelLED.off()
    sleep(.3)

while True:
    now = datetime.datetime.now()
    if now.strftime("%H") == start[0] and now.strftime("%M") == start[1] and now.strftime("%S") == "00":
        print ("Time to water!")
        yelLED.on()
        solenoid.on()
        sleep(60*mins)
        print ("All done")
        yelLED.off()
        solenoid.off()
예제 #28
0
TUB_SENSOR = '28-011592ac2bff'
OUTSIDE_SENSOR = '28-011592ac2bff'

# Define the GPIO Pins
#PIN_TEMP = 26
#PIN_JETS1 = 21
#PIN_JETS2 = 20
#PIN_AIR = 6

MAX_TEMP = 70
desired_temp = 37.0
heater_temp = 0.0
tub_temp = 0.0
outside_temp = 0.0

jets1 = LED(26)  # Relay 1
jets2 = LED(19)  # Relay 2
air = LED(13)  # Relay 3
heater = LED(6)  # Relay 4
lights = LED(5)  # Relay 5
ozone = LED(11)  # Relay 6
pin7 = LED(9)  # Relay 7
circ_pump = LED(10)  # Relay 8

flow_button = Button(8)


def lcd_init():
    # Initialise display
    lcd_byte(0x33, LCD_CMD)  # 110011 Initialise
    lcd_byte(0x32, LCD_CMD)  # 110010 Initialise
예제 #29
0
#    1 - Play extremely rarely
#    5 - Play average (default)
#    9 - Play frequently

### IMPORTS ############################################################

import time
import datetime
import random
import os

from gpiozero import LED, Button, MotionSensor
from threading import Thread

### INITIALIZATION #####################################################
laser = LED(3)
lefteye = LED(20)
righteye = LED(21)
pir = MotionSensor(16, pull_up=False, threshold=0.7)
#movement = Button(16)
laser.off()  # legacy
lefteye.on()  # shows that SW is running after bootup

random.seed(
)  # Initialize internal state of random number generator based on time
soundsnippetDir = "/home/pi/soundsnippets"

### THREADS ############################################################


class flashingLed():
예제 #30
0
from gpiozero import LED
from time import sleep

led = LED(17)