Code for Project:
All of the code written for this project is in the text file above. It is very simple code, and it is all done with simple if statements that run the desired action sequentially.
The first thing the code does, in the for loop, is check all sensors, and perform all conversion equations. This puts the values we read on the sensors into usable information for us to look at and understand. Knowing the actual values for what the sensors read, allow us to form the code that comes next.
The first few if statements are in place for running the shade. So, if the temperature reading is less than 60 degrees, the shade pivots to allow sun into the garden. This happens by the potentiometer percentage, relating to the position of the servo. Then, when the temperature is above 60 degrees, the shade pivots to block the sun from the garden. However, there is the addition of one extra if statement. This statement brings the servo to a vertical position before shifting over. This is needed, because the servo will pivot to almost horizontal in the afternoon, and needs to flip the other way to block evening sun.
The next 3 if statements are run on the pushbuttons. This is done to demonstrate the zones being checked, and gives me more control of when the system checks. This action would be done automatically when the garden is in place, and fully functional. So, what it is doing, is checking the moisture level of the zone, calculating how much water is needed, and calculating the height drop for the water collection tank and ultrasonic to measure. Now, the valve would open, and the sensor will monitor the height increase in the bucket. Once this height is achieved, the valve shuts., and we move onto the next zone.