The greenhouse controller code
Since the code of this project is perhaps a little longer than the previous examples, I will present it first by sections without comments and include the complete code for reference at the end of this chapter.
Libraries and constant definitions
We begin our code by including the servo
library that we will use to deal with the servomotor that will operate the retractable roof. We define constants that will be used all along the code as follows:
#include <Servo.h> #define redLedPin 13 #define yellowLedPin 12 #define greenLedPin 11 #define relayPin 8 #define motorPin 6 #define buzzerPin 4 #define servoPin 3 #define buttonPin 2 #define potentiometerPin 2 #define thermistorPin 1 #define photocellPin 0 #define NOTE_A4 440 ...
Get Arduino Essentials now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.