first commit
This commit is contained in:
139
ESP8266_RELAI/ESP8266_RELAI.ino
Normal file
139
ESP8266_RELAI/ESP8266_RELAI.ino
Normal file
@@ -0,0 +1,139 @@
|
||||
/*
|
||||
Blink
|
||||
|
||||
Turns an LED on for one second, then off for one second, repeatedly.
|
||||
|
||||
Most Arduinos have an on-board LED you can control. On the UNO, MEGA and ZERO
|
||||
it is attached to digital pin 13, on MKR1000 on pin 6. LED_BUILTIN is set to
|
||||
the correct LED pin independent of which board is used.
|
||||
If you want to know what pin the on-board LED is connected to on your Arduino
|
||||
model, check the Technical Specs of your board at:
|
||||
https://www.arduino.cc/en/Main/Products
|
||||
|
||||
modified 8 May 2014
|
||||
by Scott Fitzgerald
|
||||
modified 2 Sep 2016
|
||||
by Arturo Guadalupi
|
||||
modified 8 Sep 2016
|
||||
by Colby Newman
|
||||
|
||||
This example code is in the public domain.
|
||||
|
||||
http://www.arduino.cc/en/Tutorial/Blink
|
||||
*/
|
||||
|
||||
// Load the virtuabotixRTC library
|
||||
#include "virtuabotixRTC.h"
|
||||
|
||||
// Determine the pins connected to the module
|
||||
// myRTC (clock, data, RST)
|
||||
virtuabotixRTC myRTC (6, 7, 8);
|
||||
|
||||
// the setup function runs once when you press reset or power the board
|
||||
void setup() {
|
||||
// initialize digital pin LED_BUILTIN as an output.
|
||||
Serial.begin(9600);
|
||||
pinMode(2, OUTPUT);
|
||||
pinMode(3, OUTPUT);
|
||||
stop();
|
||||
// After to set the entire information, comment the following line
|
||||
// (seconds, minutes, hours, day of week, day of month, month, year)
|
||||
// myRTC.setDS1302Time (0, 18, 23, 6, 31, 7, 2021);
|
||||
}
|
||||
|
||||
// the loop function runs over and over again forever
|
||||
void loop() {
|
||||
|
||||
// Reads the information from the CI
|
||||
myRTC.updateTime ();
|
||||
printTime();
|
||||
avance();
|
||||
delay(10000); // wait for a second
|
||||
Serial.println("off");
|
||||
recule();
|
||||
delay(10000); // wait for a second
|
||||
Serial.println("On");
|
||||
|
||||
stop();
|
||||
delay(10000);
|
||||
}
|
||||
|
||||
void printTime()
|
||||
{
|
||||
// Print the details in serial monitor
|
||||
Serial.print
|
||||
("Data "); // Call the routine that prints the day of the week
|
||||
imprime_dia_da_semana (myRTC.dayofweek);
|
||||
Serial.print (", ");
|
||||
Serial.print (myRTC.dayofmonth);
|
||||
Serial.print ("/");
|
||||
Serial.print (myRTC.month);
|
||||
Serial.print ("/");
|
||||
Serial.print (myRTC.year);
|
||||
Serial.print ("");
|
||||
Serial.print
|
||||
(" Time "); // Adds a 0 if the time value is <10
|
||||
if (myRTC.hours <10)
|
||||
{
|
||||
Serial.print ("0");
|
||||
}
|
||||
Serial.print (myRTC.hours);
|
||||
Serial.print
|
||||
(":"); // Adds a 0 if the value of the minutes is <10
|
||||
if (myRTC.minutes <10)
|
||||
{
|
||||
Serial.print ("0");
|
||||
}
|
||||
Serial.print (myRTC.minutes);
|
||||
Serial.print
|
||||
(":"); // Adds a 0 if the value of the latter is <10
|
||||
if (myRTC.seconds <10)
|
||||
{
|
||||
Serial.print ("0");
|
||||
}
|
||||
Serial.println (myRTC.seconds);
|
||||
|
||||
}
|
||||
void stop()
|
||||
{
|
||||
digitalWrite(2, LOW); // turn the LED on (HIGH is the voltage level)
|
||||
digitalWrite(3, LOW);
|
||||
}
|
||||
|
||||
void avance() {
|
||||
digitalWrite(2, HIGH); // turn the LED on (HIGH is the voltage level)
|
||||
digitalWrite(3, LOW);
|
||||
}
|
||||
|
||||
void recule() {
|
||||
digitalWrite(3, HIGH); // turn the LED on (HIGH is the voltage level)
|
||||
digitalWrite(2, LOW);
|
||||
}
|
||||
|
||||
void imprime_dia_da_semana (int day)
|
||||
{
|
||||
switch (day)
|
||||
{
|
||||
case 1:
|
||||
Serial.print
|
||||
("Sunday");
|
||||
break; case 2:
|
||||
Serial.print
|
||||
("Second");
|
||||
break; case 3:
|
||||
Serial.print
|
||||
("Terca");
|
||||
break; case 4:
|
||||
Serial.print
|
||||
("Wednesday");
|
||||
break; case 5:
|
||||
Serial.print
|
||||
("Quinta");
|
||||
break; case 6:
|
||||
Serial.print
|
||||
("Friday");
|
||||
break; case 7:
|
||||
Serial.print
|
||||
("Saturday"); break;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user