Hello
I have a topic on feasibility about this
but i thought programming questions might be more suited.
I am trying to make a master clock to drive a slave clock
with an H bridge, i send a 500ms pulse using two pins to define polarity. I wait one minute then i switch the state? (high low) of two pins to reverse polarity.
this is the code
int enA = 10;
int in1 = 9;
int in2 = 8;
void setup()
{
//
pinMode(enA, OUTPUT);
pinMode(in1, OUTPUT);
pinMode(in2, OUTPUT);
}
void demoOne()
{ // pulse one pin
digitalWrite(enA, HIGH);
digitalWrite(in1, HIGH);
digitalWrite(in2, LOW);
delay(500);
digitalWrite(in1, LOW);
digitalWrite(in2, LOW);
delay(60000);
// now pulse second pin
digitalWrite(in1, LOW);
digitalWrite(in2, HIGH);
delay(500);
// now turn off
digitalWrite(in1, LOW);
digitalWrite(in2, LOW);
delay(60000);
}
void loop()
{
demoOne();
}
since it is a clock! i wanted to integrate an RTC.
here is my first problem : i dont know how to make the code run at every 00 second (every minute on the minute) or if this is even possible, if not possible i will just start the code at a corresponding time.
so i integrated an RTC code
and aarg proposed some changes that i havent been able to integrate
#include <DS1307RTC.h>
#include <Time.h>
#include <TimeAlarms.h>
#include <Wire.h>
int enA = 10;
int in1 = 9;
int in2 = 8;
void setup()
{
Serial.begin(9600);
Serial.println("In setup....");
/*
using rtc, sync system time to rtc
setTime(8,29,0,1,1,11); // set time to Saturday 8:29:00am Jan 1 2011 //old way *****************
*/
// following lines added to set time from rtc, took from timeRtcSet example, added jim *****************
setSyncProvider(RTC.get); // the function to get the time from the RTC
if (timeStatus() != timeSet)
Serial.println("Unable to sync with the RTC");
else
Serial.println("RTC has set the system time");
// end of setting the time ******************************
Alarm.timerRepeat(60, Repeats(int pinNumber)); // pulse every 60 seconds
pinMode(enA, OUTPUT);
pinMode(in1, OUTPUT);
pinMode(in2, OUTPUT);
digitalClockDisplay();
Serial.println("Ending setup....");
}
void digitalClockDisplay()
{
// digital clock display of the time
Serial.print(hour());
printDigits(minute());
printDigits(second());
Serial.println();
}
void printDigits(int digits)
{
Serial.print(":");
if(digits < 10)
Serial.print('0');
Serial.print(digits);
}
void Repeats(int pinNumber){
Serial.println("PULSE");
digitalWrite(pinNumber, HIGH);
delay(500);
digitalWrite(pinNumber, LOW);
}
void loop(){
digitalClockDisplay();
Alarm.delay(1000);
Repeats(in1);
Repeats(in2);
}
i dont really know where to declare int pinNumber , nor where i should put Repeats(in1);
Repeats(in2);
if you have a more simple solution, or something more calibrated to my [limited] understanding it would be much appreciated.
sorry, total noob trying to cut and paste my way to understanding.