-
Notifications
You must be signed in to change notification settings - Fork 0
/
SmartCoop.ino
79 lines (67 loc) · 1.6 KB
/
SmartCoop.ino
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
/*
Smart Coop: An Automated Chicken Coop
Jason Keane
04/11//17
*/
#include <Ethernet.h>
#include "smartCoop.h"
#include <time.h>
EthernetClient client;
EthernetServer server(8000);
/* GLOBAL VARIABLES - These will not always be here */
String currentLine = "";
String sunrise = "";
String sunset = "";
bool doorStatus = 0;
bool feedStatus = 0;
bool Connected = 0;
bool getTimes = true;
float temperature;
float humidity;
float insideTemperature;
void setup()
{
//Open serial and wait
Serial.begin(9600);
while (!Serial)
{}
// start the Ethernet connection:
byte mac[] = { 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xED };
IPAddress ip(192,168,41,10);
IPAddress dnsServer(8,8,8,8);
IPAddress gateway(192,168,41,1);
IPAddress subnet(255,255,255,0);
//Ethernet.begin(mac, ip, dnsServer, gateway, subnet);
Ethernet.begin(mac);
// give the Ethernet a second
delay(1000);
server.begin();
Serial.print("The server is at ");
Serial.println(Ethernet.localIP());
system("ntpdate -u 209.208.79.69"); // set the system time using NTP
// set pins
pinMode(solenoidValve, OUTPUT);
pinMode(heatLamp, OUTPUT);
pinMode(lightPin, OUTPUT);
pinMode(doorMotorEN, OUTPUT);
pinMode(doorMotorPin1, OUTPUT);
pinMode(doorMotorPin2, OUTPUT);
pinMode(doorReadSwitch1, INPUT);
pinMode(doorReadSwitch2, INPUT);
pinMode(fan, OUTPUT);
pinMode(feederMotor, OUTPUT);
digitalWrite(doorMotorEN, HIGH);
digitalWrite(feederMotor, HIGH);
}
void loop()
{
if (getTimes == true)
{
connectForGET();
}
checkDoor();
checkWaterSensor();
feedCheck();
temperatureCheckTiming();
getRealTime();
}