Welcome to Hackster!
Hackster is a community dedicated to learning hardware, from beginner to pro. Join us, it's free!
adamnearevaFabio Cardoso
Published © GPL3+

Double Plant Watering

Another plant watering system, now with a light sensor, 4 LEDs, silent pumps, and memory.

IntermediateWork in progress5,081
Double Plant Watering

Things used in this project

Hardware components

Arduino Pro Mini 328 - 3.3V/8MHz
SparkFun Arduino Pro Mini 328 - 3.3V/8MHz
×1
General Purpose Transistor NPN
General Purpose Transistor NPN
×1
1N4007 – High Voltage, High Current Rated Diode
1N4007 – High Voltage, High Current Rated Diode
×1
Photo resistor
Photo resistor
×1
Jumper wires (generic)
Jumper wires (generic)
×1
Resistor 1k ohm
Resistor 1k ohm
1/8W
×1
Breadboard (generic)
Breadboard (generic)
×1
Micro-USB to USB Cable (Generic)
Micro-USB to USB Cable (Generic)
you have to cut it
×1

Software apps and online services

Arduino IDE
Arduino IDE

Hand tools and fabrication machines

Soldering iron (generic)
Soldering iron (generic)

Story

Read more

Schematics

Schematic

Code

Double plant watering 3

Arduino
#include <LowPower.h>          //sleep library

byte ldrPin=6;                 //ldr at pin 6       
byte led1=2;                   //led1
byte led2=3;                   //led2
byte led3=4;                   //led3
byte led4=5;                   //led3
byte pump1=7;                  //pump1 at pin 7
byte pump2=8;                  //pump2 at pin 8
int tempo1=3000;               //pump1 3 seconds of watering
int tempo2=4000;               //pump2 4 seconds of watering
byte light=0;                  //variable light
int i=0;                       //time variable


void setup()                   //at the start:
{
pinMode(ldrPin,INPUT);         //ldr input
pinMode(pump1,OUTPUT);         //pump1 output
pinMode(pump2,OUTPUT);         //pump2 output
pinMode(led1,OUTPUT);          //led1 output
pinMode(led2,OUTPUT);          //led2 output
pinMode(led3,OUTPUT);          //led3 output
pinMode(led4,OUTPUT);          //led4 output
digitalWrite(pump1,LOW);       //both pump turned off
digitalWrite(pump2,LOW);
digitalWrite(led1,LOW);        //led1 off
digitalWrite(led2,LOW);        //led2 off
digitalWrite(led3,LOW);        //led3 off
digitalWrite(led4,LOW);        //led4 off
}

void loop()                    //cycle:
{
  light=digitalRead(ldrPin);   //read light
  if(light==HIGH)              //if there is the sun:
  {
   i++;                        //increase seconds
   
   if(i>=450)             //turn led1 on after an hour
   {
   digitalWrite(led1,HIGH);   
   digitalWrite(led2,LOW);
   digitalWrite(led3,LOW);
   digitalWrite(led4,LOW);
   }
   if(i>=900)             //turn led2 on after an other hour
   {
   digitalWrite(led1,HIGH);
   digitalWrite(led2,HIGH);
   digitalWrite(led3,LOW);
   digitalWrite(led4,LOW);
   }
   if(i>=1350)            //turn led3 on after an other hour
   {
   digitalWrite(led1,HIGH);
   digitalWrite(led2,HIGH);
   digitalWrite(led3,HIGH);
   digitalWrite(led4,LOW);   
   }
   if(i>=1800)             //turn led4 on after an other hour
   {
    digitalWrite(led1,HIGH);    //turn led1 on
    digitalWrite(led2,HIGH);    //turn led2 on
    digitalWrite(led3,HIGH);    //turn led3 on
    digitalWrite(led4,HIGH);    //turn led4 on
    digitalWrite(pump1,HIGH);   //turn on pump1 
    delay(tempo1);              //wait some time
    digitalWrite(pump1,LOW);    //turn off pump1
    digitalWrite(pump2,HIGH);   //turn on pump2
    delay(tempo2);              //wait some time
    digitalWrite(pump2,LOW);    //turn off pump2
    digitalWrite(led1,LOW);     //start with led off
    digitalWrite(led2,LOW);     //start with led off
    digitalWrite(led3,LOW);     //start with led off
    digitalWrite(led4,LOW);     //start with led off
    i=0;                        //reset seconds
   }   
  LowPower.powerDown(SLEEP_8S, ADC_OFF, BOD_OFF); //sleep 8s
  }
  else                          //if there is dark:
  {                             
  digitalWrite(led1,LOW);       //all led off
  digitalWrite(led2,LOW);
  digitalWrite(led3,LOW);      
  digitalWrite(led4,LOW);  
  LowPower.powerDown(SLEEP_8S, ADC_OFF, BOD_OFF); //sleep 8s
  }
}

Credits

adamneareva
3 projects • 14 followers
Contact
Fabio Cardoso
1 project • 5 followers
I am a self-employed Arduino inventor and computer teacher in a public school.
Contact

Comments

Please log in or sign up to comment.