Sign In Start Free Trial
Account

Add to playlist

Create a Playlist

Modal Close icon
You need to login to use this feature.
  • Arduino Essentials
  • Toc
  • feedback
Arduino Essentials

Arduino Essentials

By : Perea
5 (5)
close
Arduino Essentials

Arduino Essentials

5 (5)
By: Perea

Overview of this book

If you are a hobbyist who wants to develop projects based on Arduino as the main microcontroller platform or an engineer interested in finding out what the Arduino platform offers, then this book is ideal for you. Some prior knowledge of the C programming language is required.
Table of Contents (12 chapters)
close
11
Index

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
#define NOTE_A3 220
#define TEMPMIN 820
#define TEMPMAX 850
#define MEDIUMPOWER 128
#define FULLPOWER 255
#define BEGINWATERING 700
#define ENDWATERING 550
#define DAYLIGHT 400

Here is a breakdown of the 20 constants used in the preceding code...

bookmark search playlist font-size

Change the font size

margin-width

Change margin width

day-mode

Change background colour

Close icon Search
Country selected

Close icon Your notes and bookmarks

Delete Bookmark

Modal Close icon
Are you sure you want to delete it?
Cancel
Yes, Delete