Hi all,
i am trying to programm a clock with my Arduino. But i am not really understanding how the time library works.
Here is the code i have written.
#include <Time.h>
#include <TimerOne.h>
int tilt = A5;
int mts = 0;
int hrs = 0;
int scd = 0;
void setup()
{
pinMode(tilt, 0);
pinMode(10, 0);
Timer1.initialize(300); // initialize timer1
Timer1.pwm(10, 512); // setup pwm pin 10 / 50%
setTime(hrs,mts,scd,0,0,0);
}
void loop()
{
delay(50);
int tilt_x = analogRead(tilt);
if (tilt_x > 500) {
pulse();
}
else {
Timer1.disablePwm(10);
}
Serial.begin(9600);
Serial.print(scd);
Serial.print("\n");
Serial.print(mts);
Serial.print("\n");
Serial.print(hrs);
Serial.print("\n");
}
void pulse() {
Timer1.pwm(10, 512); // set pwm on pin 10, 50% duty cycle
}
So I don't know hot to get the timer work.
I wan't to set the time into the variables.