Created
March 8, 2020 02:48
-
-
Save omgjlk/5add93776275a62e5436ebfb9ba21c84 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Fin's Awesome Plant Monitor | |
import time | |
import board | |
import busio | |
import neopixel | |
from board import SCL, SDA | |
from adafruit_seesaw.seesaw import Seesaw | |
i2c_bus = busio.I2C(SCL, SDA) | |
# This is the plant sensor | |
ss = Seesaw(i2c_bus, addr=0x36) | |
# This is our light | |
led = neopixel.NeoPixel(board.NEOPIXEL, 1) | |
led.brightness = 1.0 | |
# Define our functions | |
def turn_on_led(color): | |
led.brightness = 1.0 | |
led[0] = color | |
def turn_off_led(): | |
led.brightness = 0.0 | |
# Declare desired moisture level | |
DESIRED_MOISTURE = 600 | |
# Our loop | |
while True: | |
# read moisture level through sensor | |
moisture = ss.moisture_read() | |
# Compare moisture level to desired moisture level | |
if moisture < DESIRED_MOISTURE: | |
turn_on_led(color=(255, 0, 0)) | |
else: | |
turn_off_led() | |
print("moisture: " + str(moisture)) | |
time.sleep(1) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment