Skip to main content

Sprinkler Control 1: Hardcoded Schedule

Loading...

Having worked through The Basics section of the Tutorial, you now know enough to take on a "real project." We start with a multi-step implementation of a device that is common in agriculture -- the Sprinkler (Watering) Controller. Such controllers turn the plant watering on and off according to a pre-defined schedule.

You already saw two simple applications of the Scheduler: The Scheduler project triggers the time printing every minute on the minute, while the Scheduler (Sunrise and Sunset) application synchronizes the street lights to the sunrises and sunsets. We open this chapter with a more generic example of Scheduler usage.

Let's say you want to automatically water your plants twice daily at 8 am and 4:45 pm. Each cycle should continue for five minutes.

Here is a sprinkler control application that hardcodes this logic. As you can see, the implementation comprises two schedules of the "every day at hh : mm" type and a timer.

Monitoring the Sprinkler Relay State

The same relay used in the Sunrise and Sunset project controls the sprinkler in this one. On the AppBlocks Demo Kit (ADK), this relay is connected to a green LED marked "RL1." The LED is on when the relay is on.

sprinkler_scheduler