Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ This repository was established during the course of the RoboTech project as par
### I want to extend my gratitude to my amazing teammates for their dedication and hard work.
[Ali Amgad](https://github.com/aliamgad)

[IBrahemelyamany](https://github.com/IBrahemelyamany)
[IBrahem Mohamed](https://github.com/IBrahem-Elyamany)

[Shady Atef](https://github.com/shady-ateff)

Expand Down
49 changes: 30 additions & 19 deletions main_project.ino → main_project/main_project.ino
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,10 @@ NTPClient timeClient(ntpUDP, "pool.ntp.org" , + 3*60*60); //3*60*60 cairo zone
ESP8266WebServer server(80);

String msgAr = "" ;
char * timerSTR;
String timerSTR;

long long int timer , timer1 , timer2 , timer3 , timer4 , mm ;
unsigned long timer1 , timer2 , timer3 , timer4 , mm ;
bool timer1_state = 0, timer2_state = 0, timer3_state = 0, timer4_state = 0 ;

const char* mqtt_Server = "broker.mqtt-dashboard.com";

Expand Down Expand Up @@ -111,7 +112,7 @@ void setup() {
client.setServer(mqtt_Server, 1883);
client.setCallback(callback);
timel= millis();
timer= millis();
//timer= millis();
}

Display.displayClear();
Expand Down Expand Up @@ -280,12 +281,15 @@ void callback(char* topic, byte* payload, unsigned int length) {
Serial.print((char)payload[i]);
timerSTR+=(char)payload[i];
}
mm = atol(timerSTR);
mm = timerSTR.toInt();
Serial.println();
Serial.println(mm);
if ((char)payload[0] == '0') {
timer1 = 0;
timer1_state = 0 ;
} else {
timer1 = timer + mm;
timer1 = millis() + mm;
Serial.println(timer1);
timer1_state = 1 ;
}
}
else if ( strstr(topic, "timer2"))
Expand All @@ -295,12 +299,13 @@ void callback(char* topic, byte* payload, unsigned int length) {
Serial.print((char)payload[i]);
timerSTR+=(char)payload[i];
}
mm = atol(timerSTR);
mm = timerSTR.toInt();
Serial.println();
if ((char)payload[0] == '0') {
timer2 = 0;
timer2_state = 0 ;
} else {
timer2 = timer + mm;
timer2 = millis() + mm;
timer2_state = 1 ;
}
}
else if ( strstr(topic, "timer3"))
Expand All @@ -310,12 +315,13 @@ void callback(char* topic, byte* payload, unsigned int length) {
Serial.print((char)payload[i]);
timerSTR+=(char)payload[i];
}
mm = atol(timerSTR);
mm = timerSTR.toInt();
Serial.println();
if ((char)payload[0] == '0') {
timer3 = 0;
timer3_state = 0 ;
} else {
timer3 = timer + mm;
timer3 = millis() + mm;
timer3_state = 1 ;
}
}
else if ( strstr(topic, "timer4"))
Expand All @@ -325,12 +331,13 @@ void callback(char* topic, byte* payload, unsigned int length) {
Serial.print((char)payload[i]);
timerSTR+=(char)payload[i];
}
mm = atol(timerSTR);
mm = timerSTR.toInt();
Serial.println();
if ((char)payload[0] == '0') {
timer4 = 0;
timer4_state = 0 ;
} else {
timer4 = timer + mm;
timer4 = millis() + mm;
timer4_state = 1 ;
}
}
else
Expand Down Expand Up @@ -518,20 +525,24 @@ String liveClock(){
}

void set_the_timer(){
if( timer >= timer1 && timer1 != 0 ){
if( millis() >= timer1 && timer1_state == 1 ){
digitalWrite(Relay_Led_1, LOW);
timer1_state = 0;
Relay1_state = 0;
}
if( timer >= timer2 && timer2 != 0 ){
if( millis() >= timer2 && timer2_state == 1 ){
digitalWrite(Relay_Led_2, LOW);
timer2_state = 0;
Relay2_state = 0;
}
if( timer >= timer3 && timer3 != 0 ){
if( millis() >= timer3 && timer3_state == 1 ){
digitalWrite(Relay_Led_3, LOW);
timer3_state = 0;
Relay3_state = 0;
}
if( timer >= timer4 && timer4 != 0 ){
if( millis() >= timer4 && timer4_state == 1 ){
digitalWrite(Relay_Led_4, LOW);
timer4_state = 0;
Relay4_state = 0;
}
}
Expand Down