/*
Hi All,
I want to use a real time clock to put its reading into a variable
Then I want to use the variable info to make an array.
In the case shown here how can I get the 'myText' variables contents into an array.
The variable info will change every 5 seconds
*/
String myTxt; //----------- The myTxt variable will contain changing info
//-------------------------- Type of array I want the info to go into ------------------------------------------
char myStr[] = "ABC";// --- instead of this I want to use the variable
int x;
void setup(){
Serial.begin(9600);
for (x = 0; x < sizeof(myStr) - 1; x++){
Serial.write(myStr[x]);
Serial.println();
}
}
void loop() {
}
Does you program really look like that ?
Read read this before posting a programming question and follow the advice given
Hey, so I do not know exactly waht you want to do, but if you want to make an array from some information from the clock, the getTimeStr():, getDOWStr(), are actually strings that you can actually use like arrays, so I let you a code which I use to AutoWater my plants, but I add the String example I am talking about. PD:If you just want to take a specif element like, minutes, seconds, hours, etc you can use clk.hour; clk.min, etc, clk is a variable started like:"Time clk", all I talk about here is in the code below
// DS1302: CE pin -> Arduino Digital 2
// I/O pin -> Arduino Digital 3
// SCLK pin -> Arduino Digital 4
#include <DS1302.h>
DS1302 rtc(2, 3, 4); // Reset; Data Sig; Clock Sig;
Time clk;
const int Rele_valve = 12;
String days; //***********************************************
char test[25];
void setup()
{
pinMode(Rele_valve, OUTPUT);
pinMode(13, OUTPUT);
rtc.halt(false); //Set the clock to Run Mode
rtc.writeProtect(true); //Enables Time Writting protection
Serial.begin(9600);
// The following lines can be commented out to use the values already stored in the DS1302
//rtc.setDOW(THURSDAY); // Set Day-of-Week
//rtc.setTime(11, 56, 20); // Set the time (24hr format)
//rtc.setTime(4, 43, 30); // Set the time (24hr format)
// rtc.setDate(7, 12, 2018); // Set the date
}
void loop()
{
clk = rtc.getTime();
Serial.print(rtc.getTimeStr());
Serial.print(" ");
Serial.print(rtc.getDOWStr()); //////////You can try with ***Serial.print(rtc.getDOWStr()[i]);***
Serial.print(" ");
days = rtc.getDOWStr();
delay(1000);
Serial.print("The string:");
for (int i = 0; i < days.length(); i++)
Serial.print(days[i]);
Serial.print("\n");
//Serial.println(clk.hour);
if ( (clk.hour == 4) && (clk.min >= 0) && (clk.min <= 12) || (clk.hour == 4) && (clk.min >= 29) && (clk.min <= 40) ){
digitalWrite(Rele_valve, HIGH);
digitalWrite(13, HIGH);
}else{
digitalWrite(Rele_valve, LOW);
digitalWrite(13, LOW);
}
delay (1000);
}