Assignment 6 – Watering System

The Concept

The circuit is meant to represent a form of smart plant watering system. The light sensor is meant to detect the level of hypothetical sunlight, and the switch is meant to be pressed when the hypothetical soil is dried out. When the switch is held down, there is a third LED that shows that the plants are being watered, and the brightness of this LED slowly fades out, representing that the plants have been sufficiently watered. The initial brightness of this LED is based on the reading from the light sensor, to portray that you will have to water less if the sunlight isn’t as strong. Also, if the switch isn’t held down until this LED completely fades out, it will stay on to show that more watering still needs to be down.

The circuit

The circuit consists of a light sensor hooked to the Yellow LED, and the brightness of this LED is mapped to the reading from the light sensor

if(lightValue<=400){brightness=0;}
else{brightness = map(lightValue, 400, 1023, 0, 255);}

I realized even if I fully covered the light sensor with my hand, the reading would still be around 350-400. Thus, instead of directly mapping the input from the sensor to the output for the LED brightness, I set a threshold at 400 and below, which means that at 400 I want the light to be off, as this is a negligible amount of light.

The circuit then consists of a switch hooked to the Green LED to represent whether or not the switch is held down. This LED is digital and simply turns on and off.

There is also a third Blue LED, and this is an analog LED that is impacted by both the light sensor and the switch. The LED’s brightness is determined by the variable waterLevel, and this waterLevel is slowly decremented while the switch is pressed down.

if(switchValue==1)
{
  if(waterLevel>0){
    waterLevel --; 
  }
  analogWrite(waterLEDPin, waterLevel);

The initial value of waterLevel is set by the reading of the light sensor. Therefore, both sensors contribute to the behavior of this Blue LED.

The Demo

Leave a Reply