Hello and thanks to everyone who can help me finishing my project.
First of all, im very new to Arduino but im trying and testing several examples and made it possible to to dimm 3 LED´s (to mix colours) with 1 Poti and 1 Button and stored them to EEprom to be able to read the last state after a powerloss.
Its not much but it feels great for a beginner.
All this will be used in a self createt Pond Lighting which will hopefully be able to change colour, fade in and out to simlulate a sunrise, clouds, moonlight etc... Maybe ill add some Sensors like Temp to measure the Water and some more.
Later on, when i think im able to use it, ill use a Shield to access everything via LAN or WLAN. It depends on my skill, which will hopefully increase.
But right now im messing around with time.
Im useing the example code from the Playground.
#include <Time.h>
#define TIME_MSG_LEN 11 // time sync to PC is HEADER followed by Unix time_t as ten ASCII digits
#define TIME_HEADER 'T' // Header tag for serial time sync message
#define TIME_REQUEST 7 // ASCII bell character requests a time sync message
// T1262347200 //noon Jan 1 2010
void setup() {
Serial.begin(9600);
}
void loop(){
if(Serial.available() )
{
processSyncMessage();
}
if(timeStatus() == timeNotSet)
Serial.println("waiting for sync message");
else
digitalClockDisplay();
delay(1000);
}
void digitalClockDisplay(){
// digital clock display of the time
Serial.print(hour());
printDigits(minute());
printDigits(second());
Serial.print(" ");
Serial.print(day());
Serial.print(" ");
Serial.print(month());
Serial.print(" ");
Serial.print(year());
Serial.println();
}
void printDigits(int digits){
// utility function for digital clock display: prints preceding colon and leading 0
Serial.print(":");
if(digits < 10)
Serial.print('0');
Serial.print(digits);
}
void processSyncMessage() {
// if time sync available from serial port, update time and return true
while(Serial.available() >= TIME_MSG_LEN ){ // time message consists of header & 10 ASCII digits
char c = Serial.read() ;
Serial.print(c);
if( c == TIME_HEADER ) {
time_t pctime = 0;
for(int i=0; i < TIME_MSG_LEN -1; i++){
c = Serial.read();
if( c >= '0' && c <= '9'){
pctime = (10 * pctime) + (c - '0') ; // convert digits to a number
}
}
setTime(pctime); // Sync Arduino clock to the time received on the serial port
}
}
}
I used "setTime(hr,min,sec,day,month,yr); // another way to set the time" in void lood to set the Time and it worked.
Afterwards i tryed to move it to "void processSyncMessage()" and added a pushcounter and a button and also a potentiometer and map to map the values to the required values.
I added some lines with Serial.print to see what happens but nothing worked.
Can someone help me with some lines of code which would help to set the time with a button and a potentiometer?
I know the time is not realy accurate but for testing and learning it will work.
Thanks for ur time.