找回密碼
 立即注冊

QQ登錄

只需一步,快速開始

帖子
查看: 12716|回復(fù): 7
收起左側(cè)

arduino+DS1302+dht11

[復(fù)制鏈接]
ID:276685 發(fā)表于 2018-1-17 20:43 | 顯示全部樓層 |閱讀模式
最近發(fā)現(xiàn)自己沒有個小鐘表起床看時間不方便于是就做了一個
成品!
198951865741902697.jpg
材料arduino
      ds1302
      1602  (有條件的可以使I2c)
      dht11
     電線若干

接線順序
1602---12 ,11 ,7  ,6  ,5  ,4
ds1302    ce--2
               Io--3
               sclk--9dht11----8

使用3個庫LiquidCrystal.h  DS1302.h dht11.h  
直接上原碼,沒有按鍵調(diào)時,和串口功能,以后改進

  1. #include <LiquidCrystal.h>
  2. #include <DS1302.h>
  3. #include <dht11.h>      // DHT11 傳感器程序庫

  4. // Init the DS1302
  5. DS1302 rtc(2, 3, 9);
  6. // Init the LCD
  7. LiquidCrystal lcd(12, 11, 7, 6, 5, 4);
  8. void setup()
  9. {
  10.   // Set the clock to run-mode, and disable the write protection
  11.   rtc.halt(false);
  12.   rtc.writeProtect(false);

  13.   // Setup LCD to 16x2 characters
  14.   lcd.begin(16, 2);

  15.   // The following lines can be commented out to use the values already stored in the DS1302
  16.   rtc.setDOW(TUESDAY);        // Set Day-of-Week to FRIDAY
  17.   rtc.setTime(22,05, 0);     // Set the time to 12:00:00 (24hr format)
  18.   rtc.setDate(24,10,2017);   // Set the date to August 6th, 2010
  19. }

  20. void loop(){
  21.         // Display time centered on the upper line
  22.   lcd.setCursor(1, 0);
  23.   lcd.print(rtc.getTimeStr());

  24.   // Display abbreviated Day-of-Week in the lower left corner
  25.   lcd.setCursor(12, 0);
  26.   lcd.print(rtc.getDOWStr(FORMAT_SHORT));

  27.   // Display date in the lower right corner
  28.   lcd.setCursor(6, 1);
  29.   lcd.print(rtc.getDateStr());

  30.   // Wait one second before repeating :)
  31.   delay (1000);

  32. dht11 DHT11;     // 溫濕度傳感器程序?qū)ο?br />
  33. const byte dataPin = 8;
  34.   int chk = DHT11.read(dataPin);
  35.   if (chk == 0)
  36.     lcd.setCursor(0, 1);   // 顯示溫度
  37.     lcd.print((float)DHT11.temperature, 1);
  38.     lcd.print((char) 0xDF);


  39. }
復(fù)制代碼

全部資料51hei下載地址:
數(shù)字鐘.zip (94.95 KB, 下載次數(shù): 106)


評分

參與人數(shù) 1黑幣 +50 收起 理由
admin + 50 共享資料的黑幣獎勵!

查看全部評分

回復(fù)

使用道具 舉報

ID:157550 發(fā)表于 2018-12-14 01:51 | 顯示全部樓層
不錯不錯,學(xué)習(xí)了
回復(fù)

使用道具 舉報

ID:463470 發(fā)表于 2019-1-7 09:39 | 顯示全部樓層
謝謝樓主分享。。。。。。。
回復(fù)

使用道具 舉報

ID:794756 發(fā)表于 2020-7-1 18:33 | 顯示全部樓層
在嗎, 索取arduino+DS1302+dht11 整套資料
回復(fù)

使用道具 舉報

ID:471632 發(fā)表于 2022-3-9 10:39 | 顯示全部樓層
好東西,能加上wifi自動校時更好了。
回復(fù)

使用道具 舉報

ID:138707 發(fā)表于 2023-7-29 18:44 | 顯示全部樓層
好東西,能加上wifi自動校時更好了。
回復(fù)

使用道具 舉報

ID:1075678 發(fā)表于 2023-10-14 18:53 | 顯示全部樓層
ziba108 發(fā)表于 2023-7-29 18:44
好東西,能加上wifi自動校時更好了。

想請問一下,怎么添加呢?發(fā)現(xiàn)庫里面沒有找到關(guān)于WiFi的庫文件,所以就不知道怎么繼續(xù)做了。
回復(fù)

使用道具 舉報

ID:1075678 發(fā)表于 2023-10-14 19:09 | 顯示全部樓層
想問一下這里使用的IIC功能嗎?為什么我在自己軟件上面驗證時,出現(xiàn)說void halt出現(xiàn)問題。
回復(fù)

使用道具 舉報

您需要登錄后才可以回帖 登錄 | 立即注冊

本版積分規(guī)則

小黑屋|51黑電子論壇 |51黑電子論壇6群 QQ 管理員QQ:125739409;技術(shù)交流QQ群281945664

Powered by 單片機教程網(wǎng)

快速回復(fù) 返回頂部 返回列表