Nano Smart Blog

Lets start Smart Blogs to increase your traffic on your Google Adsense

Sunday 5 June 2016

Jual Jepit IC EEPROM 93CXX / 25CXX / 24CXX - Nano Market | Tokopedia

Jual Jepit IC EEPROM 93CXX / 25CXX / 24CXX - Nano Market | Tokopedia: Jual Jepit IC EEPROM 93CXX / 25CXX / 24CXX, Komponen/IC/Kabel dengan harga Rp 150.000 dari toko online Nano Market, Semarang. Cari produk tools
Read More »

Saturday 9 April 2016

Jual USB to RS485 Converter - Nano Market | Tokopedia

Jual USB to RS485 Converter - Nano Market | Tokopedia: Jual USB to RS485 Converter, Komponen/IC/Kabel dengan harga Rp 45.000 dari toko online Nano Market, Purworejo. Cari produk lainnya di Tokopedia. Jual beli online aman dan nyaman hanya di Tokopedia.  - By Nano Proxy
Read More »

Thursday 28 May 2015

20 tahun telkomsel - SMK Muh Purwodadi

Read More »

Monday 13 April 2015

Penggunaan Dual Motor Shield Arduino

The Arduino Motor Shield allows you to easily control motor direction and speed using an Arduino. By allowing you to simply address Arduino pins, it makes it very simple to incorporate a motor into your project. It also allows you to be able to power a motor with a separate power supply of up to 12v. Best of all, the shield is very easy to find. Aside from being sold a number of places online, they are now stocked by most Radioshack stores. For all of these reasons, the Arduino Motor Shield if a cool little to have in your arsenal for rapid prototyping, and general experimenting.
 
Remove these adsRemove these ads by Signing Up

Step 1: Install

The pins of the official Arduino motor shield will only align with Arduino Uno Rev. 3.

In order to make it work with older versions of the Arduino, you will need to trim a few pins off the motor shield. However, this is not, at all, recommended.

Insert the motor shield pins into the socket of the Arduino Uno.

Step 2: Shield Features

The motor shield has 2 channels, which allows for the control of two DC motors, or 1 stepper motor.

It also has 6 headers for the attachment of Tinkerkit inputs, outputs, and communication lines. The use of these pins is somewhat limited, and therefor not covered in this tutorial.

With an external power supply, the motor shield can safely supply up to 12V and 2A per motor channel (or 4A to a single channel).

There are pins on the Arduino that are always in use by the shield. By addressing these pins you can select a motor channel to initiate, specify the motor direction (polarity), set motor speed (PWM), stop and start the motor, and monitor the current absorption of each channel .

The pin breakdown is as follows:

FunctionChannel AChannel B
DirectionDigital 12Digital 13
Speed (PWM)Digital 3Digital 11
BrakeDigital 9Digital 8
Current SensingAnalog 0Analog 1


For more information about the technical specs, check out the motor shield'sofficial page on the Arduino site.

Step 3: Program

Plug the Arduino into your computer's USB port and open the Arduino development environment.

In order to get the board to do anything, you need to initialize the motor channel by toggling three parameters:
  1. First you need to set the motor direction (polarity of the power supply) by setting it either HIGH or LOW.
  2. Then you need to disengage the brake pin for the motor channel by setting it to LOW.
  3. Finally, to get the motor to start moving, you need to set the speed by sending a PWM command (analogWrite) to the appropriate pin.

If you do not do all three of these things, the motor will not turn on.

In the following steps are some common examples of common motor setups.

Step 4: One Motor

To control a motor using the Arduino Motor Shield, first plug the motor's positive (red) wire into Channel A's + terminal on the motor shield, and the motor's ground (black) wire into Channel A's - terminal on the shield.

An external power supply is not always necessary, but it drastically improves the motor's performance. It is recommended that you always use one.

To connect your external power supply, connect the positive (red) wire from the power supply to the "Vin" terminal, and the ground (black) wire to the "GND" terminal.

Finally, upload the code to control the Motor Shield to the Arduino.

Here is the code for controlling one motor:

Step 5: Two Motors

Interfacing with two motors is pretty much the same as interfacing with one motor. Simply plug the motor into Channel B.

The only difference code-wise is that you need to engage a second channel to control the second motor.

Here is code for controlling two motors:

Step 6: Stepper Motor

There are a number of different types of stepper motors, but in this tutorial we will specifically be addressing bipolar stepper motors. Bipolar stepper motors typically have 4 pins, which correspond to two coils. To use a stepper, you need to power these two coils in phase with alternating polarity.

To figure out which two pins make up a single coil, insert an LED into any two pins on its socket and rotate the motor shaft. If the LED lights up, you found one coil. The other two pins should make up the other coil.

To make a bipolar motor spin:
  1. Power the first coil.
  2. Next power the second coil with reverse polarity.
  3. Then power the first coil with reverse polarity.
  4. Finally, power the second coil.
To reverse the motor direction of a bipolar stepper, simply reverse the polarity of the second coil.

Here is code to make the stepper spin in one direction:

Here is code to make the stepper spin in the opposite direction:

Read More »

Penggunaan Modul RF Arduino

Application environment
Remote control switch, receiver module, motorcycles, automobile anti-theft products, home security products, electric doors, shutter doors, windows, remote control socket, remote control LED, remote audio remote control electric doors, garage door remote control, remote control retractable doors, remote volume gate, pan doors, remote control door opener, door closing device control system, remote control curtains, alarm host, alarm, remote control motorcycle remote control electric cars, remote control MP3.
Receiver module parameters 
receiver only
1. Product Model: MX-05V
2. Operating voltage: DC5V
3. Quiescent Current: 4mA
4. Receiving frequency:315Mhz
5. Receiver sensitivity:-105DB
6. Size: 30 * 14 * 7mm
Technical parameters of the transmitter module
transmitter only
1. Product Model: MX-FS-03V
2. Launch distance :20-200 meters (different voltage, different results)
3. Operating voltage :3.5-12V
4. Dimensions: 19 * 19mm
5. Operating mode: AM
6. Transfer rate: 4KB / S
7. Transmitting power: 10mW
8. Transmitting frequency: 315Mhz
9. An external antenna: 25cm ordinary multi-core or single-core line
10. Pinout from left → right: (DATA; VCC; GND)
Buy now button
An example: 
In this example, receiver and transmitter modules are connected separately to two Arduino boards. The transmitter data pin is connected to Pin 12 of Arduino and the receiver data pin is connected to Pin 11 of Arduino.
315Mhz wireless transmitter and receiver (1)
Data pin of transmitter module to Pin 12 of Arduino.
Data pin of receiver module to Pin 11 of Arduino.
Please note that there are two separate Arduinos for each module.
Connecting transmitter module to Arduino:
rotate
Sketch:
12345678910111213141516171819202122
/*
SimpleSend
This sketch transmits a short text message using the VirtualWire library
connect the Transmitter data pin to Arduino pin 12
*/
#include <VirtualWire.h>
void setup()
{
// Initialize the IO and ISR
vw_setup(2000); // Bits per sec
}
void loop()
{
send("Hello there");
delay(1000);
}
void send (char *message)
{
vw_send((uint8_t *)message, strlen(message));
vw_wait_tx(); // Wait until the whole message is gone
}
 
view rawgistfile1.ino hosted with ❤ by GitHub
Connecting receiver module to Arduino:
315Mhz wireless transmitter and receiver (4)
Sketch:
12345678910111213141516171819202122232425262728
/*
SimpleReceive
This sketch displays text strings received using VirtualWire
Connect the Receiver data pin to Arduino pin 11
*/
#include <VirtualWire.h>
byte message[VW_MAX_MESSAGE_LEN]; // a buffer to store the incoming messages
byte messageLength = VW_MAX_MESSAGE_LEN; // the size of the message
void setup()
{
Serial.begin(9600);
Serial.println("Device is ready");
// Initialize the IO and ISR
vw_setup(2000); // Bits per sec
vw_rx_start(); // Start the receiver
}
void loop()
{
if (vw_get_message(message, &messageLength)) // Non-blocking
{
Serial.print("Received: ");
for (int i = 0; i < messageLength; i++)
{
Serial.write(message[i]);
}
Serial.println();
}
}
view rawgistfile1.ino hosted with ❤ by GitHub
Output:
The transmitter sends a string “Hello there” and the receiver receives it and displays on serial monitor.
New Picture (1)
Related links:
Read More »

Penggunaan Modul RTC Arduino

This time I will be showing you how to make a module for letting the Arduino find out the time. Although there are many tutorials for the Real Time Clock module I wanted to make my version of this module entirely focused on the step by step soldering. The Instructable will also try to include as much example code as possible so that the reader will get more than the basic knowledge of this module.
This module has the integrated time keeping system using a crystal oscillator. So the timing is accurate with multiple applications. This module also has a battery backup with which the module can keep track of the time even when the Arduino is programmed or turned off. Lets start off with the stuff you will learn and the applications of this module.

Stuff You Will Learn:

  • The code required to access the module and get the current time.
  • The code for setting the time.
  • A simple program with which the user can interact with the module.

Uses of The Project:

  • Once you are done with this Instructable you will be able to make your own Digital Clock.
  • You can build on the idea and make an Alarm Clock.
  • This Module is the timekeeper for many projects like The Propeller Clock, The Nixie Clock, etc.

Components Required:

Component for the Module:
Additional Components:
When I designed this module I ignored the square wave pin, Since I didn't find it useful in my application but you may add an extra pin if the need arises.
 
{"uid":1,"hostPeerName":"http://www.instructables.com","initialGeometry":"{\"windowCoords_t\":0,\"windowCoords_r\":1360,\"windowCoords_b\":704,\"windowCoords_l\":0,\"frameCoords_t\":1997,\"frameCoords_r\":820.5,\"frameCoords_b\":2247,\"frameCoords_l\":520.5,\"styleZIndex\":\"auto\",\"allowedExpansion_t\":0,\"allowedExpansion_r\":0,\"allowedExpansion_b\":0,\"allowedExpansion_l\":0,\"xInView\":0,\"yInView\":0}","permissions":"{\"expandByOverlay\":true,\"expandByPush\":false,\"readCookie\":false,\"writeCookie\":false}","metadata":"{\"shared\":{\"sf_ver\":\"1-0-2\",\"ck_on\":1,\"flash_ver\":\"17.0.0\"}}","reportCreativeGeometry":false}" scrolling="no" marginwidth="0" marginheight="0" width="300" height="250" data-is-safeframe="true" style="border-width: 0px; vertical-align: bottom;">
Remove these adsRemove these ads by Signing Up

Step 1: About The DS 1307

Introduction:

Apart from the arduino the DS1307 Integrated Circuit is the core of this project since it acts as the timekeeper and tells the arduino when it should leave the appliance on. The DS 1307 is specifically designed for timekeeping, The time is fairly accurate with an error (time drift) of about 1 minute per month. If u want to eliminate this u can go for the DS3234 which has a time drift of only 1 minute per year. For our particular application we can settle for the DS1307 itself.
The beauty of the DS1307 is that it has this backup coin cell. This Coin Cell is commonly the CR2032. This battery is more than enough for the IC since the DS1307 has a fairly low power consumption the backup battery life of the cell is about a minimum of 9 years of usage.
So now that the specs have been discussed lets talk about the communication. The DS 1307 communicates with the arduino using I²C communication. Simply put the chip sends data in decimal form such that each decimal form is 4 bits of binary data also known as Binary Coded Decimal System.

Important Pins:

5V Pin: When this pin is high then the ds1307 sends the data and when it is low it runs on the backup button cell.
GND: This is the ground pin for the module. Both the ground of the battery and the power supply are tied together.
SCL: It is the i2c clock pin - Which communicates with the RTC.
SDA: It is the i2c data pin - Which communicates with the RTC.
So now that the introductions are done lets get to actually making the module. The instructable has steps of the soldering and the places of the components in the board. Hope this method is better to understand than just providing the circuit diagram.

Step 2: Assembly and Soldering - 1

So the module is only 2 x 3 cm in size, which is pretty compact. The module has a wire connector but you can also use a male or female header so that it can be directly plugged into the Arduino. Anyway apart from the square wave pin not soldered the module has all the functional features.

Making The Module:

Step 1:
Cut the prototype board to the size mentioned above and insert the coin cell holder. Then solder the bottom end to hold the cell in its place.
Step 2:
Insert the DIP socket right next to the cell holder but leave space for the crystal oscillator like in the diagram. Solder some pins to hold the socket in place.
Step 3:
Now insert the crystal Oscillator near the first and second pin of the DIP Socket as shown in the figure. Then solder it as shown.
Note 1:
This note is for showing the colour code for my 4 pin connector for reference, since yours may vary please double check that the proper connections are made.
Note 2:
Now we need to connect the battery terminals using the tracks as shown in the diagram. These connections provide the backup power.

Step 3: Assembly and Soldering - 2

Step 5:
Now insert the power pins coming from the Arduino. The positive pin goes to the eighth pin of the DS 1307. Then the ground is common for the IC and the button cell.
Step 6:
In this step we connect the other two data pins coming from the Arduino as shown in the figure. I'm sorry because I made the module a little small so there was no hole for the 10k resistor. I inserted both the resistor and the wire in the same pin and then soldered.
Step 7:
So after you inserted the wires next we need to insert 10k resistors each into the two pins. The other ends of the two resistors goes to the power pin eight of the DS 1307. Then solder up the wires, a diagram is provided for reference.
Step 8:
Since I use a connector in this module frequent usage will lead to wear and tear of the wires. So i made a joint using the cut of wire from the resistors. First insert the wire into one end and solder it to make it sturdy. Then make a U-bend and pass the wires through this U-bend and tighten the U-bend for a good grip and then solder the other end too to make a joint. The diagram explains the method better than words.
The module is finally finished so insert both the battery and the DS1307 IC into their sockets. The final diagram shows the completed module with all intact.

Step 4: Checking and Setting The Module

Once you are done assembling the module. Connect the module to the Arduino, so that the pins are inserted properly into the Arduino. The program for testing the module is given below. The code constantly updates the time through the serial port.
In-order to run the module we need two libraries we need two libraries into the Arduino software. The following steps set up the Arduino software with the libraries needed and the code.

Importing The Libraries:

  • Download the library "RealTimeClockDS1307" and save it in the desktop.
  • Open the Arduino and go to Sketch => Import Library => Add Library.
  • Then select the library saved in the desktop and click add.
  • Now paste the sample code given below and click compile. If it compiles successfully then skip the remaining steps.
  • If it doesn't import the second library "Wire" and repeat the same procedure and compile the code and it will work.

Code Working:

The code is written by "David H. Brown" I merely use it to give you an introduction to the DS1307. Anyway the Arduino communicates with the RTC Module and updates the time for every second through the Serial Monitor. The creator has given us a option to set the time when we send the command "?". The following menu appears.
Try these:
 h## - set Hours [range 1..12 or 0..24]
 i## - set mInutes [range 0..59]
 s## - set Seconds [range 0..59]
 d## - set Date [range 1..31]
 m## - set Month [range 1..12]
 y## - set Year [range 0..99]
 w## - set arbitrary day of Week [range 1..7]
 t   - toggle 24-hour mode
 a   - set AM          p   - set PM

 z   - start clock     Z   - stop clock
 q   - SQW/OUT = 1Hz   Q   - stop SQW/OUT
This code will help you to set the time as well as check if the module's backup battery supply works properly. In the next tutorial I will show you how to setup a LCD Display and display the time from the RTC module. Here is the code for testing the module and an attached file of the same.
#include <Wire.h>
#include <RealTimeClockDS1307.h>

//RealTimeClock RTC;//=new RealTimeClock();

#define Display_Clock_Every_N_Seconds 10           // n.secs to show date/time
#define Display_ShortHelp_Every_N_Seconds 60       // n.secs to show hint for help
//#define TEST_Squarewave
//#define TEST_StopStart
//#define TEST_1224Switch

int count=0;
char formatted[] = "00-00-00 00:00:00x";

void setup() {
//  Wire.begin();
  Serial.begin(9600);
    pinMode(A3, OUTPUT);     //*** pin 16 (Analog pin 2) as OUTPUT   ***
  digitalWrite(A3, HIGH);   //*** pin 16 (Analog pin 2) set to LOW  ***
  pinMode(A2, OUTPUT);     //*** pin 17 (Analog pin 3) as OUTPUT   ***
  digitalWrite(A2, LOW);  //*** pin 17 (Analog pin 3) set to HIGH ***
  //*** Analog Pin settings to power RTC module ***
}
 
void loop() {
  if(Serial.available())
  {
    processCommand();
  }

  RTC.readClock();
  count++;
  if(count % Display_Clock_Every_N_Seconds == 0){
    Serial.print(count);
    Serial.print(": ");
    RTC.getFormatted(formatted);
    Serial.print(formatted);
    Serial.println();
  }
  
  if(count % Display_ShortHelp_Every_N_Seconds == 0) {
    Serial.println("Send ? for a list of commands.");
  }
#ifdef TEST_Squarewave
if(count%10 == 0)
{
  switch(count/10 % 6)
  {
    case 0:
    Serial.print("Squarewave disabled (low impedance): ");
    RTC.sqwDisable(0);
    Serial.println((int) RTC.readData(7));
    break;
    case 1:
    Serial.print("Squarewave disabled (high impedance): ");
    RTC.sqwDisable(1);
    Serial.println((int) RTC.readData(7));
    break;
    case 2:
    Serial.println("Squarewave enabled at 1 Hz");
    RTC.sqwEnable(RTC.SQW_1Hz);
    break;
    case 3:
    Serial.println("Squarewave enabled at 4.096 kHz");
    RTC.sqwEnable(RTC.SQW_4kHz);
    break;
    case 4:
    Serial.println("Squarewave enabled at 8.192 kHz");
    RTC.sqwEnable(RTC.SQW_8kHz);
    break;
    case 5:
    Serial.println("Squarewave enabled at 32.768 kHz");
    RTC.sqwEnable(RTC.SQW_32kHz);
    break;
    default:
    Serial.println("Squarewave test not defined");
  }//switch
}
#endif

#ifdef TEST_StopStart
if(count%10 == 0)
{
  if(!RTC.isStopped()) 
  {
    if(RTC.getSeconds() < 45) 
    {
      Serial.println("Stopping clock for 10 seconds");
      RTC.stop();
    }//if we have enough time
  } else {
    RTC.setSeconds(RTC.getSeconds()+11);
    RTC.start();
    Serial.println("Adding 11 seconds and restarting clock");
  }
}//if on a multiple of 10 counts
#endif

#ifdef TEST_1224Switch  
  if(count%10 == 0)
  {
    if(count %20 == 0)
    {
      Serial.println("switching to 12-hour time");
      RTC.switchTo12h();
      RTC.setClock();
    }
    else
    {
      Serial.println("switching to 24-hour time");
      RTC.switchTo24h();
      RTC.setClock();
    }
  }
#endif
}

void processCommand() {
  if(!Serial.available()) { return; }
  char command = Serial.read();
  int in,in2;
  switch(command)
  {
    case 'H':
    case 'h':
    in=SerialReadPosInt();
    RTC.setHours(in);
    RTC.setClock();
    Serial.print("Setting hours to ");
    Serial.println(in);
    break;
    case 'I':
    case 'i':
    in=SerialReadPosInt();
    RTC.setMinutes(in);
    RTC.setClock();
    Serial.print("Setting minutes to ");
    Serial.println(in);
    break;
    case 'S':
    case 's':
    in=SerialReadPosInt();
    RTC.setSeconds(in);
    RTC.setClock();
    Serial.print("Setting seconds to ");
    Serial.println(in);
    break;
    case 'Y':
    case 'y':
    in=SerialReadPosInt();
    RTC.setYear(in);
    RTC.setClock();
    Serial.print("Setting year to ");
    Serial.println(in);
    break;
    case 'M':
    case 'm':
    in=SerialReadPosInt();
    RTC.setMonth(in);
    RTC.setClock();
    Serial.print("Setting month to ");
    Serial.println(in);
    break;
    case 'D':
    case 'd':
    in=SerialReadPosInt();
    RTC.setDate(in);
    RTC.setClock();
    Serial.print("Setting date to ");
    Serial.println(in);
    break;
    case 'W':
    Serial.print("Day of week is ");
    Serial.println((int) RTC.getDayOfWeek());
    break;
    case 'w':
    in=SerialReadPosInt();
    RTC.setDayOfWeek(in);
    RTC.setClock();
    Serial.print("Setting day of week to ");
    Serial.println(in);
    break;
    
    case 't':
    case 'T':
    if(RTC.is12hour()) {
      RTC.switchTo24h();
      Serial.println("Switching to 24-hour clock.");
    } else {
      RTC.switchTo12h();
      Serial.println("Switching to 12-hour clock.");
    }
    RTC.setClock();
    break;
    
    case 'A':
    case 'a':
    if(RTC.is12hour()) {
      RTC.setAM();
      RTC.setClock();
      Serial.println("Set AM.");
    } else {
      Serial.println("(Set hours only in 24-hour mode.)");
    }
    break;
    
    case 'P':
    case 'p':
    if(RTC.is12hour()) {
      RTC.setPM();
      RTC.setClock();
      Serial.println("Set PM.");
    } else {
      Serial.println("(Set hours only in 24-hour mode.)");
    }
    break;

    case 'q':
    RTC.sqwEnable(RTC.SQW_1Hz);
    Serial.println("Square wave output set to 1Hz");
    break;
    case 'Q':
    RTC.sqwDisable(0);
    Serial.println("Square wave output disabled (low)");
    break;
    
    case 'z':
    RTC.start();
    Serial.println("Clock oscillator started.");
    break;
    case 'Z':
    RTC.stop();
    Serial.println("Clock oscillator stopped.");
    break;
    
    case '>':
    in=SerialReadPosInt();
    in2=SerialReadPosInt();
    RTC.writeData(in, in2);
    Serial.print("Write to register ");
    Serial.print(in);
    Serial.print(" the value ");
    Serial.println(in2);
    break;    
    case '<':
    in=SerialReadPosInt();
    in2=RTC.readData(in);
    Serial.print("Read from register ");
    Serial.print(in);
    Serial.print(" the value ");
    Serial.println(in2);
    break;

    default:
    Serial.println("Unknown command. Try these:");
    Serial.println(" h## - set Hours [range 1..12 or 0..24]");
	Serial.println(" i## - set mInutes [range 0..59]");
	Serial.println(" s## - set Seconds [range 0..59]");
	Serial.println(" d## - set Date [range 1..31]");
    Serial.println(" m## - set Month [range 1..12]");
    Serial.println(" y## - set Year [range 0..99]");
    Serial.println(" w## - set arbitrary day of Week [range 1..7]");
    Serial.println(" t   - toggle 24-hour mode");
    Serial.println(" a   - set AM          p   - set PM");
    Serial.println();
    Serial.println(" z   - start clock     Z   - stop clock");
    Serial.println(" q   - SQW/OUT = 1Hz   Q   - stop SQW/OUT");
    Serial.println();
    Serial.println(" >##,###  - write to register ## the value ###");
    Serial.println(" <##      - read the value in register ##");
    
  }//switch on command
  
}

//read in numeric characters until something else
//or no more data is available on serial.
int SerialReadPosInt() {
  int i = 0;
  boolean done=false;
  while(Serial.available() && !done)
  {
    char c = Serial.read();
    if (c >= '0' && c <='9')
    {
      i = i * 10 + (c-'0');
    }
    else 
    {
      done = true;
    }
  }
  return i;
}

Step 5: About the Library

Before going to display the time in the LCD. I wanted to discuss about the library that we imported. I omitted the library which needs the square wave data since the module has no square wave output pin. Lets discuss about the various keywords involved in this library with some examples.

KEYWORDS:

Start Clock:
RTC.start();
This can be used to start up the clock and it will start ticking from the time when it was stopped. This command should be used when first using the module in-order to start the module.
Stop Clock:
RTC.stop();
With this line the module can be paused and clock wont tick until the start command is given. It is used with the start clock command to control the module's state.
Read Clock:
RTC.readClock();
After the clock is turned on using the Start command. You need to read the data from the RTC module. This is done by the readClock function. This function is essential before the latter commands can be used.
Reading the time:
//integers for holding the various time values.
int hours = 0;
int minutes = 0;
int seconds = 0;
int dates = 0;
int months = 0;
int years = 0;
int date = 0;
//syntax for setting the values to the integers
RTC.readClock();   //This line is essential for the other commands to work.
//Commands for getting the individual time values.
hours = RTC.getHours();
minutes = RTC.getMinutes();
seconds = RTC.getSeconds();
dates = RTC.getDate();
months = RTC.getMonth();
years = RTC.getYear();
date = RTC.getDayofWeek();
//finally just print the stored data (refer next step).
So once the readClock is called. Next we need to store the individual values in integers. We create integers for holding the values. The getDayofWeek function give the day it is in the week. With the first day being Monday and the last is Sunday. Note that this method is very inefficient when compared to the code in the previous steps but this will help you understand the working of the various functions in the library.
NOTE:
//extra code for finding out whether its AM or PM when the clock is in 12h mode.
//declare an integer and string.
int AP = 0;
String TZ;
//then read the data from the module.
ampm = RTC.isPM();
//use an if loop to find out whether its AM or PM.
if(ampm == 1)
{
    am = "PM";
}
else
{
    am ="AM";
}
This extra line of code will display whether its AM or PM when in 12-hour mode. When you set it to 24-hour mode remove this code.
Writing the time:
RTC.setHours(4);
RTC.setMinutes(35);
RTC.setSeconds(14);
RTC.setDate(9);
RTC.setMonth(6);
RTC.setYear(14);
RTC.set24h();
//RTC.setAM();
RTC.setPM();
RTC.setDayofWeek(1);<br>
So these are the commands for setting the time for the Module. As you can see i have set the time for 4:35:14 PM with the date as 9/6/14. Apart from these commands there is the set24h command which directly sets the clock into 24hour mode and set AM and PM for setting it into 12hour mode. The setDayofWeek is used to set the day.
Time commands:
//These commands deal with the settings in the module.

//Checks whether the clock is running.
RTC.isStopped();
//Check whether it is AM or PM depending on the output(given above).
RTC.isPM();
//Checks whether the clock is in 24hour mode.
RTC.is12hour();
//Toggles between the 12hour mode and 24hour mode.
RTC.switchTo24h();
These are the commands that control the settings inside the clock.
I have explained as much as I can about this library. If you find any flaws or something I missed please comment about it so that it can be as accurate as possible.

Step 6: Displaying the Time (Simple Method)

Now that the module is checked, now lets work on getting the time data to display on the LCD. The LCD module can be easily connected to the Arduino. The circuit diagram for connecting the LCD module is shown. The code for displaying the time is given below.
Before that I have made two versions of this code. One with the ordinary LCD connected to the Arduino. This is the simplest version but this will occupy most of the pins in the Arduino. So I came up with an alternative, using a Shift register to send data to the LCD module using only 2 pins. So you may choose whichever is more convenient for you.

Normal Version:

More pins but simpler!
So connect up the LCD as shown in the breadboard diagram. Then just upload the code into the Arduino and the date and time will be displayed in the LCD Display. So here's the code.

CODE:

#include <Wire.h>
#include <RealTimeClockDS1307.h>
#include <LiquidCrystal.h>

LiquidCrystal lcd(12, 11, 5, 4, 3, 2);

#define Display_Clock_Every_N_Seconds 10 
#define Display_ShortHelp_Every_N_Seconds 60
String tz;
int hours = 0;
int minutes = 0;
int seconds = 0;
int dates = 0;
int months = 0;
int years = 0;
int ap = 0;
void setup() {
  Serial.begin(9600);
  lcd.begin(16,2); 
  pinMode(A3, OUTPUT);
  digitalWrite(A3, HIGH);
  pinMode(A2, OUTPUT);
  digitalWrite(A2, LOW);
}

void loop() {
  RTC.readClock();
    if(ap == 1)
    {
    tz = "PM";
    }
    else
    {
    tz ="AM";
    }
    lcd.home();
    hours = RTC.getHours();
    minutes = RTC.getMinutes();
    seconds = RTC.getSeconds();
    ap = RTC.isPM();
    dates = RTC.getDate();
    months = RTC.getMonth();
    years = RTC.getYear();
    lcd.print(hours);
    lcd.print(":");
    lcd.print(minutes);
    lcd.print(":");
    lcd.print(seconds);
    lcd.print(" ");
    lcd.print(tz);
    lcd.setCursor(0, 1);
    lcd.print(dates);
    lcd.print(":");
    lcd.print(months);
    lcd.print(":");
    lcd.print(years);
    delay(250);
    lcd.clear();
    lcd.home();
    lcd.print(hours);
    lcd.print(" ");
    lcd.print(minutes);
    lcd.print(" ");
    lcd.print(seconds);
    lcd.print(" ");
    lcd.print(tz);
    lcd.setCursor(0, 1);
    lcd.print(dates);
    lcd.print(" ");
    lcd.print(months);
    lcd.print(" ");
    lcd.print(years);
    delay(250);
    lcd.clear();
}
After connecting the RTC module and uploading the code. The LCD will display the time in the top row and the date in the bottom row. This version is useful for learning the basic commands and let you to use these commands in your future projects.

Step 7: Displaying The Time (Shift Register Version)

Shift Register LCD Version:

This version used The Shift Register module to send data to the LCD using only two pins instead of six pins. This module can be bought but I wanted to make it. The full instructions on making the module are given in this link COMING SOON!!!. So just connect the two pins of the Arduino to the module and upload the code given below and the same output will be observed like in the simple version.

CODE:

#include <Wire.h>
#include <RealTimeClockDS1307.h>
#include <LiquidCrystal_SR.h>

LiquidCrystal_SR lcd(8,7,TWO_WIRE);

#define Display_Clock_Every_N_Seconds 10 
#define Display_ShortHelp_Every_N_Seconds 60
String tz;
int hours = 0;
int minutes = 0;
int seconds = 0;
int dates = 0;
int months = 0;
int years = 0;
int ap = 0;
void setup() {
//  Wire.begin();
  Serial.begin(9600);
  lcd.begin(16,2); 
  
    pinMode(A3, OUTPUT);
  digitalWrite(A3, HIGH);
  pinMode(A2, OUTPUT);
  digitalWrite(A2, LOW);
}

void loop() {
  RTC.readClock();
    ap = RTC.isPM();
    if(ap == 1)
    {
    tz = "PM";
    }
    else
    {
    tz ="AM";
    }
    lcd.home();
    hours = RTC.getHours();
    minutes = RTC.getMinutes();
    seconds = RTC.getSeconds();
    dates = RTC.getDate();
    months = RTC.getMonth();
    years = RTC.getYear();
    lcd.print(hours);
    lcd.print(":");
    lcd.print(minutes);
    lcd.print(":");
    lcd.print(seconds);
    lcd.print(" ");
    lcd.print(tz);
    lcd.setCursor(0, 1);
    lcd.print(dates);
    lcd.print(":");
    lcd.print(months);
    lcd.print(":");
    lcd.print(years);
    delay(250);
    lcd.clear();
    lcd.home();
    lcd.print(hours);
    lcd.print(" ");
    lcd.print(minutes);
    lcd.print(" ");
    lcd.print(seconds);
    lcd.print(" ");
    lcd.print(tz);
    lcd.setCursor(0, 1);
    lcd.print(dates);
    lcd.print(" ");
    lcd.print(months);
    lcd.print(" ");
    lcd.print(years);
    delay(250);
    lcd.clear();
}
This second code uses a different library if you already have this module, please use this library for the above code to work.
We finally reached the end of this instructable. I hope that after reading this the viewer has obtained more than the basic knowledge of the DS1307 RTC Module. If you have any corrections or suggestions please comment below. Till next time bye.
Read More »
Nano smart blog found result for your search: