C1 Group 1
Published

Plant Watering System

A Plant watering system for busy folk

BeginnerShowcase (no instructions)251
Plant Watering System

Things used in this project

Story

Read more

Code

Code

Python
from m5stack import *
from m5ui import *
from uiflow import *
import time
import unit

setScreenColor(0x222222)
earth0 = unit.get(unit.EARTH, unit.PORTB)
servo1 = unit.get(unit.SERVO, unit.PORTA)





label0 = M5TextBox(14, 109, "Text", lcd.FONT_DejaVu18, 0xffffff, rotate=0)
rectangle1 = M5Rect(-94, 190, 1000, 50, 0xff0000, 0xFFFFFF)
rectangle2 = M5Rect(-101, 0, 1000, 50, 0x22ff00, 0xFFFFFF)


while True:
  rectangle1.hide()
  rectangle2.show()
  servo1.write_angle(0)
  if (earth0.analogValue) <= 20:
    rectangle1.show()
    rectangle2.hide()
    rgb.setColorAll(0xff0000)
    label0.setColor(0xff0000)
    label0.setText('MOISTURE LOW, WATERING...')
    servo1.write_angle(90)
    speaker.tone(800, 200)
    wait(2)
    speaker.tone(800, 0)
  else:
    rectangle1.hide()
    rectangle2.show()
    rgb.setColorAll(0x000000)
    label0.setColor(0x33ff33)
    label0.setText('MOISTURE LEVEL OK')
    servo1.write_angle(0)
  wait_ms(2)

Credits

C1 Group 1

C1 Group 1

0 projects • 0 followers

Comments

Add projectSign up / Login