예제 #1
0
파일: server.py 프로젝트: ktkirk/HSSI
 def __init__(self):
     self.button = None
     self.encoder = None
     self.light = None
     self.relay = None
     self.speaker = None
     self.motion = None
     self.lcd = None
     # Create the Grove LED object using GPIO pin 13
     self.led = grove.GroveLed(13)
     self.servo = None
     # Create the temperature sensor object using I2C
     self.th = th02.TH02()
     self.uv_sensor = None
예제 #2
0
def main():
    # Create the Grove LED object using GPIO pin 2
    led = grove.GroveLed(2)

    # Print the name
    print led.name()

    # Turn the LED on and off 10 times, pausing one second
    # between transitions
    for i in range(0, 10):
        led.on()
        time.sleep(1)
        led.off()
        time.sleep(1)

    # Delete the Grove LED object
    del led
예제 #3
0
파일: main.py 프로젝트: zcool99/CodeLabs
import pyupm_th02 as temp

from datetime import datetime
from telegram.ext import Updater, CommandHandler, MessageHandler, Filters

credentials = ConfigParser.ConfigParser()
credentialsfile = "credentials.config"
credentials.read(credentialsfile)
controlmode = 1
Angle = 0
weather = pywapi.get_weather_from_weather_com('MXJO0043')

# Create the button object using D3
button = grove.GroveButton(3)
#Create the led object using D2
led = grove.GroveLed(2)
# Create the servo object using D6
gServo = servo.ES08A(6)
# Initialize Jhd1313m1 at 0x3E (LCD_ADDRESS) and 0x62 (RGB_ADDRESS)
myLcd = lcd.Jhd1313m1(0, 0x3E, 0x62)
# Create the light sensor object using AIO pin 2
light = grove.GroveLight(2)
# Create the temperature sensor object using AIO pin 2
#temp = grove.GroveTemp(2)
# Create relay object using D5
relay = grove.GroveRelay(5)
# Initialize TH02 temperature sensor at 0x40
gTemp = temp.TH02(0, 0x40)

# Initialize servo to 0 degrees
gServo.setAngle(Angle)
예제 #4
0
import time
import pyupm_grove as grove
# Create the Grove LED object using GPIO pin 2
led = grove.GroveLed(8)
# Print the name
print led.name()
# Turn the LED on and off 10 times, pausing one second
# between transitions
for i in range(0, 10):
    led.on()
    time.sleep(1)
    led.off()
    time.sleep(1)
# Delete the Grove LED object
del led
예제 #5
0
파일: led.py 프로젝트: ktkirk/HSSI
# included in all copies or substantial portions of the Software.
#
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
# LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

from __future__ import print_function
import time
import pyupm_grove as grove

# Create the Grove LED object using GPIO pin 13
led = grove.GroveLed(13)

# Print the name
print(led.name())

# Turn the LED on and off 10 times, pausing one second
# between transitions
for i in range (0,10):
    led.on()
    time.sleep(1)
    led.off()
    time.sleep(1)

# Delete the Grove LED object
del led
예제 #6
0
# The above copyright notice and this permission notice shall be
# included in all copies or substantial portions of the Software.
#
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
# LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

import time
import pyupm_grove as grove

# Create the Grove LED object using GPIO pin 2
led = grove.GroveLed(7)

# Print the name
print led.name()

# Turn the LED on and off 10 times, pausing one second
# between transitions
for i in range(0, 10):
    led.on()
    time.sleep(1)
    led.off()
    time.sleep(1)

# Delete the Grove LED object
del led
예제 #7
0
import pyupm_grove as g
from time import sleep

if __name__ == '__main__':

    led = g.GroveLed(4)

    led.on()
    sleep(1.5)
    led.off()
    sleep(1.5)
예제 #8
0
# ========= * CONSTANTS * ================ #

# Pins used in your Grove kit. Adjust for your led, servo, and sensor.
LED_PIN = 8
TEMP_PIN = 0
SERVO_PIN = 5

# Minimum and maximum safe angle for the servo.
MIN_ANGLE = 30
MAX_ANGLE = 150

# Temperature threshold for the alarm in Celsius degrees.
MAX_TEMP = 28

# ========= * SETTING UP GPIOS * ========= #
led = pyupm_grove.GroveLed(LED_PIN)
servo = pyupm_servo.ES08A(SERVO_PIN)
temp_sensor = pyupm_grove.GroveTemp(TEMP_PIN)

led_flag = False

# ========= * PROJECT FUNCTIONS * ======== #


# ------------ Temperature sensor -------- #
def temperatureFunction():
    """
        Read temperature, triggers the alarm, and adjusts servo's angle.
    """

    # Read temperature and trigger alarm if necessary
 def get_actuator(self):
     return pyupm_grove.GroveLed(self.pin)
예제 #10
0
from telegram.ext import Updater, CommandHandler, MessageHandler, 
Filters
import pyupm_grove as grove

led = grove.GroveLed(4)
def iniciar(bot, update):
	bot.sendMessage(update.message.chat_id, text='Hola prueba LED')
def enciende(bot, update):
	led
def apagado(bot, update):


while True:
  entrada1 = pin2.read()
  entrada2 = pin4.read()
  salida = entrada1 & entrada2
  print salida
  led.write(salida)
  time.sleep(1) 
 
예제 #11
0
import pyupm_ttp223 as ttp

# Pins used in Grove kit.
EMERGENCY_BUTTON = 3
ALERT_LED = 4

# Alarm status.
ON = True
OFF = False
alarm_status_list = {ON: "on", OFF: "off"}

# Succes code for Bluetooth commands.
SUCCESS_CODE = "OK"

# Initialize your devices.
alarm_led = grove.GroveLed(ALERT_LED)
emergency_button = ttp.TTP223(EMERGENCY_BUTTON)

# Initialize flags.
initialized = False
emergency_button_released = True
alarm_status = OFF


def toggleAlarm(alarmed):
    global alarm_status

    if alarmed:
        alarm_led.on()
        alarm_status = ON
    else:
예제 #12
0
from telegram.ext import Updater, CommandHandler, MessageHandler, Filters
import pyupm_grove as grove
import mraa

light = grove.GroveLight(3)
ledg = grove.GroveLed(8)
led = mraa.Gpio(13)
led.dir(mraa.DIR_OUT)


# Definimos manejadores de comandos. Toman normalmente dos argumentos: bot y
# update. Los manejadores de errores tambien reciben un objeto TelegramError que contienen informacion del error.
def iniciar(bot, update):
    bot.sendMessage(update.message.chat_id, text='Hola, bienvenido!')


def ledon(bot, update):
    led.write(1)
    ledg.on()
    print "Enciendo"


def ledoff(bot, update):
    led.write(0)
    ledg.off()


def obtenluz(bot, update):
    luz = light.value()
    bot.sendMessage(update.message.chat_id,
                    text='Sensor de luz con valor=%6d' % luz)