Loading presentation...

Present Remotely

Send the link below via email or IM

Copy

Present to your audience

Start remote presentation

  • Invited audience members will follow you as you navigate and present
  • People invited to a presentation do not need a Prezi account
  • This link expires 10 minutes after you close the presentation
  • A maximum of 30 users can follow your presentation
  • Learn more about this feature in our knowledge base article

Do you really want to delete this prezi?

Neither you, nor the coeditors you shared it with will be able to recover it again.

DeleteCancel

Make your likes visible on Facebook?

Connect your Facebook account to Prezi and let your likes appear on your timeline.
You can change this under Settings & Account at any time.

No, thanks

e

No description
by

Will Tsui

on 1 December 2013

Comments (0)

Please log in to add your comment.

Report abuse

Transcript of e

谢谢
代码部分
作品完成图
遇到的一些困难
电工基地作品:
具有火焰报警和温湿度显示作用的多功能电子钟

硬件部分
1 .Arduino 开发板
2 .DS1302 时钟模块
3 .DHT11数字温湿度传感器
4 .LCD1602
5 .蜂鸣器
6 .火焰传感器

Arduino,是一个基于开放原始码的软硬体平台,构建于开放原始码simple I/O介面版,并且具有使用类似Java,C语言的Processing/Wiring开发环境。
美信生产的时钟模块,支持年、月、日、时、分、秒、星期显示。支持为后备电池充电。
DHT11数字温湿度传感器是一款含有已校准数字信号输出的温湿度复合传感器,它应用专用的数字模块采集技术和温湿度传感技术,确保产品具有极高的可靠性和卓越的长期稳定性。
火焰传感器
蜂鸣器
I2C接口的LCD1602
#include <stdio.h>
#include <string.h>
#include <DS1302.h>
#include <Wire.h>
#include <LiquidCrystal_I2C.h>
int flame = A3 ;
int Beep = 9 ;
int val = 0 ;
uint8_t CE_PIN = 5 ;
uint8_t IO_PIN = 6 ;
uint8_t SCLK_PIN = 7 ;
char buf[100];
char day[10];
LiquidCrystal_I2C lcd(0x27, 16, 2);
DS1302 rtc(CE_PIN, IO_PIN, SCLK_PIN);
int DHpin = 8 ;
byte dat[5];

byte read_data()
{
byte data;
for (int i = 0; i < 8; i++)
{
if (digitalRead(DHpin) == LOW)
{
while (digitalRead(DHpin) == LOW)
;
delayMicroseconds(30);
if (digitalRead(DHpin) == HIGH)
data |= (1 << (7-i));
while (digitalRead(DHpin) == HIGH)
;
}
}
return data;
}

void start_test( )
{
digitalWrite(DHpin, LOW);
delay(30);
digitalWrite(DHpin, HIGH);
delayMicroseconds(40);
pinMode(DHpin, INPUT);
while (digitalRead(DHpin) == HIGH)
;
delayMicroseconds(80);
if (digitalRead(DHpin) == LOW)
;
delayMicroseconds(80);
for (int i = 0; i < 4; i++)
dat[i] = read_data();
pinMode(DHpin, OUTPUT);
digitalWrite(DHpin, HIGH);
}

void print_time()
{
Time t = rtc.time();
memset(day, 0, sizeof(day));
switch (t.day)
{
case 1:
strcpy(day, "Sun");
break;
case 2:
strcpy(day, "Mon");
break;
case 3:
strcpy(day, "Tue");
break;
case 4:
strcpy(day, "Wed");
break;
case 5:
strcpy(day, "Thu");
break;
case 6:
strcpy(day, "Fri");
break;
case 7:
strcpy(day, "Sat");
break;
}
snprintf(buf, sizeof(buf), "%s %02d-%02d %02d:%02d ", day, t.mon, t.date,
t.hr, t.min);
lcd.setCursor(0, 0);
lcd.print(buf);
}

void print_temhum( )
{
lcd.setCursor(0, 1);
lcd.print("H=");
lcd.print(dat[0], DEC);
lcd.print('.');
lcd.print(dat[1], DEC);
lcd.print('%');
lcd.print('0');
lcd.print("T=");
lcd.print(dat[2], DEC);
lcd.print('.');
lcd.print(dat[3], DEC);
lcd.write(B11011111);
lcd.print('C');
delay(500);
val = analogRead(flame);
}

void fire_alarm( )
{if (val >= 600)
{
digitalWrite(Beep, HIGH);
lcd.clear();
lcd.print("FIRE! FIRE!");
}
else
{
digitalWrite(Beep, LOW);
}
}

void loop( )
{
start_test( );
print_temhum( );
fire_alarm( );
print_time( );
delay(100);
}

void setup( )
{
pinMode(flame, INPUT);
pinMode(Beep, OUTPUT);
pinMode(DHpin, OUTPUT);
lcd.init( );
lcd.backlight( );
rtc.write_protect(false);
rtc.halt(false);
Time t(2013, 11, 17, 21, 21, 0, 6);
rtc.time(t);
}

焊电路板失败
时钟模块错乱
检查线路连接
经过软件的不断调试
依然没有解决
后来在百度百科上发现这样一句话:

DS1302 存在时钟精度不高,易受环境影响,出现时钟混乱等缺点。
制作人 徐威
电气与电子工程学院
1306 班
Full transcript