def regsetup(): print("ran setup") global alarmTime global wakeSounds global sensor global i2c global dist global stopMusic alarmTime = int(input("enter wake up time eg. 6, 15 for 6:25 ")) wakeSounds = input("what do you want me to say? ") i2c = busio.I2C(board.SCL, board.SDA) sensor = adafruit_vcnl4010.VCNL4010(i2c) dist = sensor.proximity stopMusic = False
# SPDX-FileCopyrightText: 2017 Tony DiCola for Adafruit Industries # SPDX-License-Identifier: MIT # Simple demo of the VCNL4010 proximity and light sensor. # Will print the proximity and ambient light every second. import time import board import busio import adafruit_vcnl4010 # Initialize I2C bus and VCNL4010 module. i2c = busio.I2C(board.SCL, board.SDA) sensor = adafruit_vcnl4010.VCNL4010(i2c) # You can optionally adjust the sensor LED current. The default is 200mA # which is the maximum value. Note this is only set in 10mA increments. # sensor.led_current_mA = 120 # Set 120 mA LED current # You can also adjust the measurement frequency for the sensor. The default # is 390.625 khz, but these values are possible to set too: # - FREQUENCY_3M125: 3.125 Mhz # - FREQUENCY_1M5625: 1.5625 Mhz # - FREQUENCY_781K25: 781.25 Khz # - FREQUENCY_390K625: 390.625 Khz (default) # sensor.frequency = adafruit_vcnl4010.FREQUENCY_3M125 # 3.125 Mhz # Main loop runs forever printing the proximity and light level. while True: proximity = sensor.proximity # Proximity has no units and is a 16-bit
help="Delete images after classifcation if true") args = parser.parse_args() _USE_TEST_MODE = args.test _USE_BLOB_STORAGE = args.blobstorage _DELETE_IMAGES = args.deleteimages if (_USE_TEST_MODE): log.info("Starting in TEST Mode") if (_USE_BLOB_STORAGE): log.info("Blob Storage Enabled.") connect_storage_account() if (_DELETE_IMAGES): log.info("Deleting images after classification.") if args.sensor == 'vcnl4010': log.info("Calibrating VCNL4010 motion sensor") i2c = busio.I2C(board.SCL, board.SDA) vcnl = adafruit_vcnl4010.VCNL4010(i2c) percent = calibratePSensor(vcnl) flash_led = LED(23) #LED connected on GPIO pin 23 if args.sensor == 'vcnl4040': log.info("Calibrating VCNL4040 motion sensor") i2c = busio.I2C(board.SCL, board.SDA) vcnl = adafruit_vcnl4040.VCNL4040(i2c) percent = calibratePSensor(vcnl) flash_led = LED(23) #LED connected on GPIO pin 23 if args.sensor == 'motion': log.info("Using Motion Sensor") move_sensor = MotionSensor( 17) #Motion Sensor control connected to GPIO pin 17 red_led = LED(18) #LED connected to GPIO pin 18 try:
def _setup(neopixels): i2c = busio.I2C(board.SCL, board.SDA) prox_sensor = adafruit_vcnl4010.VCNL4010(i2c) pixels = neopixel.NeoPixel(*neopixels) return i2c, prox_sensor, pixels