/* * ChickenDoor.cpp Part 2 * * Created on: Jan 28, 2013 * Author: John */ /* * Requirements/Specs: * Close door at night, open door at sunrise. * Motor to move door can go forward and reverse. * Limit switches exist to detect opened and closed. */ /* * Note: as is quite often the case, * the high-level stuff is at the bottom * and the low-level geeky stuff is at the top * * We call this, of course, Top-Down Design * (and, "The Source Code *is* the Design") * * So if you missed Part 1, you should probably start at the bottom * */ void startMotorOpening(){ } void startMotorClosing(){ } void stopMotor(){ } void startMotorWhichEverWayMakesSense(){ } bool sunriseDetected(){ } bool sunsetDetected(){ } bool openedLimitDetected(){ } bool closedLimitDetected(){ } bool manualButtonPushDetected(){ } void loop(){ if (sunriseDetected()) startMotorOpening(); if (sunsetDetected()) startMotorClosing(); if (openedLimitDetected()) stopMotor(); if (closedLimitDetected()) stopMotor(); if (manualButtonPushDetected()) startMotorWhichEverWayMakesSense(); } /* * This will almost compile. In the next part we will make it do so... */