Right now I am trying to build an automatic lock with arduino but there are specific times set by the user that cause the lock to activate but I can't find an arduino compatible clock/timer that would cause the device to be activated
(deleted)
DS3231
Maybe you should Google: "Arduino Clock Module" before you ask it here immediately on the forums...
It's really easy to find.
RTC is the common abbreviation. I bet if you googled "arduino RTC" you'd find a tonne of promising information.
Hi, RTC info and code HERE
The only problem is that those clocks that I have checked out before don't make it very clear whether they have programmable alarms, for example at so and so time X happens.
Your sketch keeps time updated using the battery baked up RTC.
You can examine this time in your code and when things match your code makes things "happen".
.
Larry, is there a way we can talk privately, I feel that you know what you're talking about
(deleted)
See the Time and TimeAlarms libraries with examples.
Also stay with the DS3231 RTC.
http://playground.arduino.cc/Code/time
.
How do I hook up the DS3231 RTC to the Arduino board, do I need something additional?
Wires.
If the RTC does not come with a battery you will need a coin cell installed.
Probably a 2032
.
Buy a DS3231 breakout board, and read it with the Wire library:
/* Clock with RTC, output to serial
061316 clh 3602/398 flash/ram on a UNO
Connect A4 on the UNO to SDA on the RTC
" A5 " " " " SCL " " "
" GND " " " " GND " " "
" 5V " " " " VIN " " "
Upload and open the serial monitor window.
Assuming the time has been set on the RTC,
the hours:minutes:seconds will scroll down
the serial monitor window, one line a second.
*/
#include "Wire.h"
#define rtcAddress 0x68
unsigned long previousSecondMillis;
const long oneSecond = 1000UL;
void setup()
{
Wire.begin();
Serial.begin(9600);
previousSecondMillis = millis();
}
void loop() {
if (millis() - previousSecondMillis >= oneSecond) {
previousSecondMillis += oneSecond; // do this once a second
// get bcd data from the rtc
Wire.beginTransmission(rtcAddress); // 0x68 is DS3231 device address
Wire.write((byte)0); // start at register 0
Wire.endTransmission();
Wire.requestFrom(rtcAddress, 3); // request three bytes (seconds, minutes, hours)
while (Wire.available())
{
byte seconds = Wire.read(); // get seconds
byte minutes = Wire.read(); // get minutes
byte hours = Wire.read(); // get hours
// convert BCD to decimal: (number & 0b11110000) is the 'tens place' digit
// and (number & 0b00001111) is the 'ones place' digit
// of a two digit, decimal number (as are the hours, minutes and seconds)
seconds = ((seconds & 0b11110000) >> 4) * 10 + (seconds & 0b00001111);
minutes = ((minutes & 0b11110000) >> 4) * 10 + (minutes & 0b00001111);
hours = ((hours & 0b00110000) >> 4) * 10 + (hours & 0b00001111);
// serial.print the values
Serial.print(hours);
Serial.print(':');
Serial.print(minutes);
Serial.print(':');
Serial.println(seconds);
}
}
}
Is there a diagram on how to hook all this together, the battery, the arduino and the everything, I'm only a novice at all this
If you use the RTC I linked to, and an Arduino Uno, the wiring is given in my code. Power your Arduino from the USB port of your computer. Once you understand how to use the Arduino and RTC, you will be ready to change it to your liking.
ps,
roie_moyal:
Larry, is there a way we can talk privately, I feel that you know what you're talking about
Larry does know what he talks about, as do many folks here. Fortunately for us learners, it's pretty easy to tell who does and who doesn't know what they talking are about, because the culture here is to quickly call out, and correct misinformation.
This place is based on learners asking questions, and those with experience or knowledge answering publicly. A lot of folks like to use the socratic method, where the learner is lead through a few ideas, arriving "on their own" at the answer. It's pretty effective as long as every one is polite and honest. It makes informative and entertaining reading for other learners.
The key is keeping the conversations open to the general readership.
pps, private lessons are usually expensive.
@roie_moyal
Do not delete your posts.
.
Sorry, it was a double post.
Regarding the programming, how can I use the clock for "@0800 X happens @2200 Y happens (Servo motor activates)