O'Reilly logo

Arduino Essentials by Francis Perea

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

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 ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required