Semester assignment for the course "Microprocessors and Peripherals" of THMMY in AUTH university.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

66 lines
1.6 KiB

6 years ago
#ifndef PROJECT_GROOT_H
#define PROJECT_GROOT_H
6 years ago
/* ===== INCLUDES ===== */
#include <SevSeg.h>
#include <DHT.h>
/* ===== DEFINITIONS ===== */
// Type of DHT sensor used is 11
#define DHTTYPE DHT11
// Number of readings to average
#define BUFFER_SIZE 24
// Interval between readings in milliseconds
6 years ago
#define SLEEP_INTERVAL 5000
6 years ago
// Duration of average temperature display
6 years ago
#define TEMPERATURE_DISPLAY_DURATION 10000
6 years ago
// Number of digits on the display
#define NUMBER_OF_DIGITS 4
// Pin layout
#define DHTPIN 2
#define DIST_ECHO_PIN 10
#define DIST_TRIG_PIN 11
6 years ago
#define LOW_TEMP_LED_PIN 3
#define HIGH_TEMP_LED_PIN 4
#define RELAY_PIN 5
#define DIGIT_1_PIN 14
#define DIGIT_2_PIN 17
#define DIGIT_3_PIN 18
#define DIGIT_4_PIN 12
#define SEGMENT_A_PIN 15
#define SEGMENT_B_PIN 19
#define SEGMENT_C_PIN 7
#define SEGMENT_D_PIN 8
#define SEGMENT_E_PIN 9
6 years ago
#define SEGMENT_F_PIN 16
#define SEGMENT_G_PIN 6
6 years ago
#define DECIMAL_POINT_PIN 13
// Temperature thresholds
6 years ago
#define LOW_TEMP 20
#define HIGH_TEMP 24
#define HIGH_TEMP_RELAY 26
// Distance threshold
#define DIST_THRESHOLD 10
6 years ago
#define CASE_HIGH_TEMP 0
#define CASE_LOW_TEMP 1
#define CASE_AVERAGE_TEMP 2
6 years ago
/* ===== GLOBAL VARIABLES AND INITIALIZATIONS ===== */
// Initializes DHT sensor
DHT dht(DHTPIN, DHTTYPE);
// Instantiates a seven segment object
SevSeg sevseg;
int temperatureReadingsCounter;
float temperatures[BUFFER_SIZE];
float averageTemp = 0;
unsigned long lastReading = 0, displayTimeStart = 0;
6 years ago
/* ===== FUNCTION DEFINITIONS ===== */
void getNewSamples();
float getNewTemp();
float calcAverageTempAndReset();
float getDistance();
6 years ago
6 years ago
#endif //PROJECT_GROOT_H