Pages: [1]   Go Down
Author Topic: clock (second and minutes)  (Read 742 times)
0 Members and 1 Guest are viewing this topic.
Offline Offline
Jr. Member
**
Karma: 0
Posts: 88
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

i need make clock display second and minutes using arduino UNO R3
Logged

Cape Town South Africa
Offline Offline
Edison Member
*
Karma: 19
Posts: 1217
A newbie with loads of posts, and still so much to learn !
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

do a search in the box at the top of this page  for "clock display "  or similar, there have been many projects to give you ideas
Logged

With my mobile phone I can call people and talk to them -  how smart can you get ?

Offline Offline
Jr. Member
**
Karma: 0
Posts: 88
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

how i can set timer in arduino
Logged

Cape Town South Africa
Offline Offline
Edison Member
*
Karma: 19
Posts: 1217
A newbie with loads of posts, and still so much to learn !
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

You can either go through the examples and learn gradually,  or you can post on the " gigs and collaborations " and see if someone will design it for you for money.
Logged

With my mobile phone I can call people and talk to them -  how smart can you get ?

Seattle, WA USA
Offline Offline
Brattain Member
*****
Karma: 601
Posts: 48543
Seattle, WA USA
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Quote
how i can set timer in arduino
Why do you think you need to?
Logged

Offline Offline
Newbie
*
Karma: 0
Posts: 12
There are 10 types of people in this world; those that understand binary numbers and those that don't.
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Does this help?

/*
** Arduino sketch to display date, time temperature and humidity.
** Uses LCD2004 display, Tiny RTC and DHT11 temperature and humidity sensor.
** All parts are readily found on eBay
**
** NOTES:
**    I2C pins are A4 SDA, A5 SCL on UNO, 20 SDA and 21 SCL on MEGA 2560.
**    DHT11 data connects to Pin 12. 
**    Displays time in 12 hour format.
**    Only reads DHT11 sensor every x seconds for smooth time updating
**     
**
**
** Written by Kuhntucker
** LICENSE: GNU General Public License, version 3 (GPL-3.0)
*/
unsigned long readint=15; //Read DHT11 every readint seconds.
unsigned long lasttemptime; //Used to restrict reading DHT11 to every readint seconds.
#include <LiquidCrystal_I2C.h>
#include <Wire.h>
#include <RTClib.h>
#include "DHT.h"

#define I2C_ADDR    0x3F  // Define I2C Address where the SainSmart LCD is
#define BACKLIGHT_PIN     3
#define En_pin  2
#define Rw_pin  1
#define Rs_pin  0
#define D4_pin  4
#define D5_pin  5
#define D6_pin  6
#define D7_pin  7
LiquidCrystal_I2C   lcd(I2C_ADDR,En_pin,Rw_pin,Rs_pin,D4_pin,D5_pin,D6_pin,D7_pin);

#define DHTPIN 12     // DHT11 Data Pin
#define DHTTYPE DHT11   // For DHT 11 sensor
 
DHT dht(DHTPIN, DHTTYPE);
RTC_DS1307 RTC;

void setup()
{
  lcd.begin (20,4);
  Wire.begin();
  RTC.begin();
 
  //Set the clock to the date & time this sketch was compiled.
  if (! RTC.isrunning()) {
     RTC.adjust(DateTime(__DATE__, __TIME__));
  }
 
  // Switch on the backlight and prep the LCD
  lcd.setBacklightPin(BACKLIGHT_PIN,POSITIVE);
  lcd.setBacklight(HIGH);
  lcd.clear();
  lcd.home ();
 
  writetemphumid(0,2);  //wwrites initial temp and humidity
  lasttemptime=millis(); 
} //End setup

void loop()
{
  writedate(0,0);
  writetime(0,1);
  if(millis()-lasttemptime>1000*readint) //Reads DHT11 every readint seconds
  {
    writetemphumid(0,2);
    lasttemptime=millis();
  }
  if(millis()<lasttemptime) //Resets lasttemptime and reads DHT11 on millis() rollover, ~every 49 days.
  {
    writetemphumid(0,2);
    lasttemptime=millis();
    lcd.print("did it");
  } 
}  //End Loop

//function to write the time
void writetime(int col, int row)
{
  byte timehour;
  DateTime now = RTC.now(); //read the clock
  timehour = byte(now.hour());
  lcd.setCursor (col, row);
  if (timehour>12) timehour=(timehour-12);
  if (timehour==0) timehour=12; 
  lcd.print(timehour, DEC);
  lcd.print(':');
  if (now.minute()<=9) lcd.print("0");
  lcd.print(now.minute(), DEC);
  lcd.print(':');
  if (now.second()<=9) lcd.print("0");
  lcd.print(now.second(), DEC);
  lcd.print(" ");
  if (now.hour()>12) lcd.print("PM  "); else lcd.print("AM  ");
}  //End writetime

//function to write the date
void writedate(int col, int row)
{
  int daynumber;
  char* weekday[]={"Sunday=0 ", "Monday ", "Tuesday ", "Wednesday ",
                  "Thursday ", "Friday ", "Saturday ", "Sunday=1 "};
  DateTime now = RTC.now(); //read the clock
  if (now.hour()==0 && now.minute()==0 && now.second()<2)
  {
    lcd.setCursor(col, row);
    lcd.print("                    ");
  } 
  lcd.setCursor(col, row);
  daynumber = now.dayOfWeek();
  lcd.print(weekday[daynumber]);
  if (now.month()<=9) lcd.print("0");
  lcd.print(now.month(), DEC);
  lcd.print('/');
  if (now.day()<=9) lcd.print("0");
  lcd.print(now.day(), DEC);
  lcd.print('/');
  lcd.print(now.year(), DEC);
}  //End writedate

//function to write temperature and humidity
void writetemphumid (int col, int row)
{
  float h = dht.readHumidity();
  float t = dht.readTemperature();
  // check if returns are valid, if they are NaN (not a number) then something went wrong!
  if (isnan(t) || isnan(h))
  {
    lcd.setCursor(col,row);
    lcd.print("Failed to read from DHT");
  }
   else {
    t=(9.0*t/5.0)+32.0;
    lcd.setCursor (col, row);
    lcd.print("Temp: ");
    lcd.print(int(t));
    lcd.print(" F");
    lcd.setCursor ( 0, (row+1));
    lcd.print("Humidity: ");
    lcd.print(int(h));
    lcd.print("%");
  }   
}  //Endwritetemphumid
Logged

Cape Town South Africa
Offline Offline
Edison Member
*
Karma: 19
Posts: 1217
A newbie with loads of posts, and still so much to learn !
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

After you Paul .. :-)
Logged

With my mobile phone I can call people and talk to them -  how smart can you get ?

Pages: [1]   Go Up
Jump to: