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.

63 lines
1.6 KiB

6 years ago
#ifndef TODO_FIND_COOL_NAME_FOR_PROJECT_H
#define TODO_FIND_COOL_NAME_FOR_PROJECT_H
/* ===== 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
#define SLEEP_INTERVAL 1000 // ----> TODO 5000
6 years ago
// Duration of average temperature display
#define TEMPERATURE_DISPLAY_DURATION 2000 // ----> TODO 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
#define LOW_TEMP 28
#define HIGH_TEMP 28
#define HIGH_TEMP_RELAY 32
// Distance threshold
#define DIST_THRESHOLD 10
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
#endif //TODO_FIND_COOL_NAME_FOR_PROJECT_H