0
  • 聊天消息
  • 系統(tǒng)消息
  • 評論與回復
登錄后你可以
  • 下載海量資料
  • 學習在線課程
  • 觀看技術(shù)視頻
  • 寫文章/發(fā)帖/加入社區(qū)
會員中心
創(chuàng)作中心

完善資料讓更多小伙伴認識你,還能領(lǐng)取20積分哦,立即完善>

3天內(nèi)不再提示

基于Arduino構(gòu)建一個學校自動鈴聲控制系統(tǒng)

科技觀察員 ? 來源:homemade-circuits ? 作者:homemade-circuits ? 2023-07-27 10:34 ? 次閱讀

在這篇文章中,我們將使用 Arduino、16 x 2顯示器和實時時鐘模塊構(gòu)建一個自動校鈴/大學鈴聲系統(tǒng)。您可以對此項目進行編程,使其每天在您喜歡的時間和分鐘敲鐘多達 16次。鈴聲的長度可以在幾秒鐘內(nèi)編程。

概述

當學校的牡丹敲響“錫錫丁”的鈴聲時,學生們飛快地跑出學校門口的日子已經(jīng)一去不復返了。當牡丹在幾分鐘前敲響最后一聲鐘聲時,有些人可能會更高興。

這是15到20年前的情況,但現(xiàn)在所有的學校和學院都嚴格限制時間,鐘聲是自動化的。

作者的快速童年/青少年時期記得:

在我上小學和中學時,我佩戴的數(shù)字手表與學校的鈴鐺系統(tǒng)同步,精度為1秒。

上課鈴響起后,我會大喊“下課鈴要響5秒了”,所有學生都驚訝地盯著我,這種情況幾乎每天都在發(fā)生。有一天,我和我的好朋友開始倒數(shù)10,9,8,7...在最后的鐘聲之前。

顯示到 Arduino 連接

顯示到 Arduino 連接與我們通常接線的略有不同,此處使用的引腳 9、8、7、6、5 和 4。引腳 2 和 3 通過按鈕用作硬件中斷。

使用 10K 電位計調(diào)整顯示器的對比度。

阿杜伊諾校鈴液晶顯示器

使用Arduino的自動學校/大學鈴聲系統(tǒng)

有關(guān)鐘形和繼電器連接的詳細信息

帶有Arduino的學校鈴聲計時器電路

更新:A5 到 SCL 和 A4 到 SDA(不是 A4 到 SCK)

實時時鐘模塊

實時時鐘模塊即使在長時間斷電后也能跟蹤時間。提供 9V 繼電器,用于打開和關(guān)閉鈴鐺。

請在繼電器上連接一個反向偏置的 1N4007 二極管(原理圖中未顯示),這將吸收繼電器有害的高壓反電動勢。

使用9V / 500mA墻上適配器為電路供電。

提供了三個按鈕,一個用于在某些情況下手動操作鈴鐺。按下“退出”按鈕將在手動按鈴后停止鈴鐺。

“鈴鐺禁用按鈕”將永遠禁用鈴鐺。要重新啟用鈴鐺,請按“退出”按鈕。

上傳下面的程序,它將時間設(shè)置為 RTC

//----------------------------------------------------//

#include 《Wire.h》

#include 《TimeLib.h》

#include 《DS1307RTC.h》

int P=A3; //Assign power pins for RTC

int N=A2;

const char *monthName[12] = {

“Jan”, “Feb”, “Mar”, “Apr”, “May”, “Jun”,

“Jul”, “Aug”, “Sep”, “Oct”, “Nov”, “Dec”

};

tmElements_t tm;

void setup() {

pinMode(P,OUTPUT);

pinMode(N,OUTPUT);

digitalWrite(P,HIGH);

digitalWrite(N,LOW);

bool parse=false;

bool config=false;

// get the date and time the compiler was run

if (getDate( DATE ) && getTime( TIME )) {

parse = true;

// and configure the RTC with this info

if (RTC.write(tm)) {

config = true;

}

}

Serial.begin(9600);

while (!Serial) ; // wait for Arduino Serial Monitor

delay(200);

if (parse && config) {

Serial.print(“DS1307 configured Time=”);

Serial.print( TIME );

Serial.print(“, Date=”);

Serial.println( DATE );

} else if (parse) {

Serial.println(“DS1307 Communication Error :-{”);

Serial.println(“Please check your circuitry”);

} else {

Serial.print(“Could not parse info from the compiler, Time=”“);

Serial.print( TIME );

Serial.print(”“, Date=”“);

Serial.print( DATE );

Serial.println(”“”);

}

}

void loop() {

}

bool getTime(const char *str)

{

int Hour, Min, Sec;

if (sscanf(str, “%d:%d:%d”, &Hour, &Min, &Sec) != 3) return
false;

tm.Hour = Hour;

tm.Minute = Min;

tm.Second = Sec;

return true;

}

bool getDate(const char *str)

{

char Month[12];

int Day, Year;

uint8_t monthIndex;

if (sscanf(str, “%s %d %d”, Month, &Day, &Year) != 3) return
false;

for (monthIndex = 0; monthIndex 《 12; monthIndex++) {

if (strcmp(Month, monthName[monthIndex]) == 0) break;

}

if (monthIndex 》= 12) return false;

tm.Day = Day;

tm.Month = monthIndex + 1;

tm.Year = CalendarYrToTm(Year);

return true;

}

//----------------------------------------------------//

After uploading the code, open the serial monitor, it will say that the
time is set.

Once the above step is accomplished successfully move on to next.

Now upload the below code to Arduino.

Main program Code:

//------------Program developed by R.GIRISH------------//

#include《EEPROM.h》

#include 《Wire.h》

#include 《TimeLib.h》

#include 《DS1307RTC.h》

#include 《LiquidCrystal.h》

LiquidCrystal lcd(9, 8, 7, 6, 5, 4);

int i = 0;

int H = 0;

int M = 0;

int S = 0;

int setting_value;

const int bell = 10;

const int P = A3;

const int N = A2;

const int setting_address = 0;

const int over_ride_off = 11;

boolean bell_status = true;

boolean Over_ride = true;

//------------------- Set Bell Timings from hours 1 to 23 hrs
-------------------//

//---- 1st bell ------//

const int h1 = 0; //hours

const int m1 = 0; //Minutes

//---- 2nd bell ------//

const int h2 = 0;

const int m2 = 0;

//---- 3rd bell ------//

const int h3 = 0;

const int m3 = 0;

//---- 4th bell ------//

const int h4 = 0;

const int m4 = 0;

//---- 5th bell ------//

const int h5 = 0;

const int m5 = 0;

//---- 6th bell ------//

const int h6 = 0;

const int m6 = 0;

//---- 7th bell ------//

const int h7 = 0;

const int m7 = 0;

//---- 8th bell ------//

const int h8 = 0;

const int m8 = 0;

//---- 9th bell ------//

const int h9 = 0;

const int m9 = 0;

//---- 10th bell ------//

const int h10 = 0;

const int m10 = 0;

//---- 11th bell ------//

const int h11 = 0;

const int m11 = 0;

//---- 12th bell ------//

const int h12 = 0;

const int m12 = 0;

//---- 13th bell ------//

const int h13 = 0;

const int m13 = 0;

//---- 14th bell ------//

const int h14 = 0;

const int m14 = 0;

//---- 15th bell ------//

const int h15 = 0;

const int m15 = 0;

//---- 16th bell ------//

const int h16 = 0;

const int m16 = 0;

//--------------- bell ring lenght in seconds -------//

const int Lenght = 3; //in seconds

//-------------------------- -------------------------//

void setup()

{

lcd.begin(16, 2);

pinMode(P, OUTPUT);

pinMode(N, OUTPUT);

pinMode(bell, OUTPUT);

pinMode(over_ride_off, INPUT);

digitalWrite(P, HIGH);

digitalWrite(N, LOW);

digitalWrite(over_ride_off, HIGH);

attachInterrupt(0, over_ride, RISING);

attachInterrupt(1, bell_setting, RISING);

if (EEPROM.read(setting_address) != 1)

{

bell_setting();

}

}

void loop()

{

tmElements_t tm;

lcd.clear();

if (RTC.read(tm))

{

H = tm.Hour;

M = tm.Minute;

S = tm.Second;

lcd.setCursor(0, 0);

lcd.print(“TIME:”);

lcd.print(tm.Hour);

lcd.print(“:”);

lcd.print(tm.Minute);

lcd.print(“:”);

lcd.print(tm.Second);

lcd.setCursor(0, 1);

lcd.print(“DATE:”);

lcd.print(tm.Day);

lcd.print(“/”);

lcd.print(tm.Month);

lcd.print(“/”);

lcd.print(tmYearToCalendar(tm.Year));

} else {

if (RTC.chipPresent())

{

lcd.setCursor(0, 0);

lcd.print(“RTC stopped?。。 保?

lcd.setCursor(0, 1);

lcd.print(“Run SetTime code”);

} else {

lcd.clear();

lcd.setCursor(0, 0);

lcd.print(“Read error!”);

lcd.setCursor(0, 1);

lcd.print(“Check circuitry!”);

}

}

if (EEPROM.read(setting_address) == 1)

{

if (H == 0 && M == 0 && S == 0)

{

digitalWrite(bell, LOW);

}

if (H == h1 && M == m1 && S == 0)

{

for (i = 0; i 《 Lenght; i++)

{

digitalWrite(bell, HIGH);

delay(1000);

}

digitalWrite(bell, LOW);

i = 0;

}

if (H == h2 && M == m2 && S == 0)

{

for (i = 0; i 《 Lenght; i++)

{

digitalWrite(bell, HIGH);

delay(1000);

}

digitalWrite(bell, LOW);

i = 0;

}

if (H == h3 && M == m3 && S == 0)

{

for (i = 0; i 《 Lenght; i++)

{

digitalWrite(bell, HIGH);

delay(1000);

}

digitalWrite(bell, LOW);

i = 0;

}

if (H == h4 && M == m4 && S == 0)

{

for (i = 0; i 《 Lenght; i++)

{

digitalWrite(bell, HIGH);

delay(1000);

}

digitalWrite(bell, LOW);

i = 0;

}

if (H == h5 && M == m5 && S == 0)

{

for (i = 0; i 《 Lenght; i++)

{

digitalWrite(bell, HIGH);

delay(1000);

}

digitalWrite(bell, LOW);

i = 0;

}

if (H == h6 && M == m6 && S == 0)

{

for (i = 0; i 《 Lenght; i++)

{

digitalWrite(bell, HIGH);

delay(1000);

}

digitalWrite(bell, LOW);

i = 0;

}

if (H == h7 && M == m7 && S == 0)

{

for (i = 0; i 《 Lenght; i++)

{

digitalWrite(bell, HIGH);

delay(1000);

}

digitalWrite(bell, LOW);

i = 0;

}

if (H == h8 && M == m8 && S == 0)

{

for (i = 0; i 《 Lenght; i++)

{

digitalWrite(bell, HIGH);

delay(1000);

}

digitalWrite(bell, LOW);

i = 0;

}

if (H == h9 && M == m9 && S == 0)

{

for (i = 0; i 《 Lenght; i++)

{

digitalWrite(bell, HIGH);

delay(1000);

}

digitalWrite(bell, LOW);

i = 0;

}

if (H == h10 && M == m10 && S == 0)

{

for (i = 0; i 《 Lenght; i++)

{

digitalWrite(bell, HIGH);

delay(1000);

}

digitalWrite(bell, LOW);

i = 0;

}

if (H == h11 && M == m11 && S == 0)

{

for (i = 0; i 《 Lenght; i++)

{

digitalWrite(bell, HIGH);

delay(1000);

}

digitalWrite(bell, LOW);

i = 0;

}

if (H == h12 && M == m12 && S == 0)

{

for (i = 0; i 《 Lenght; i++)

{

digitalWrite(bell, HIGH);

delay(1000);

}

digitalWrite(bell, LOW);

i = 0;

}

if (H == h13 && M == m13 && S == 0)

{

for (i = 0; i 《 Lenght; i++)

{

digitalWrite(bell, HIGH);

delay(1000);

}

digitalWrite(bell, LOW);

i = 0;

}

if (H == h14 && M == m14 && S == 0)

{

for (i = 0; i 《 Lenght; i++)

{

digitalWrite(bell, HIGH);

delay(1000);

}

digitalWrite(bell, LOW);

i = 0;

}

if (H == h15 && M == m15 && S == 0)

{

for (i = 0; i 《 Lenght; i++)

{

digitalWrite(bell, HIGH);

delay(1000);

}

digitalWrite(bell, LOW);

i = 0;

}

if (H == h16 && M == m16 && S == 0)

{

for (i = 0; i 《 Lenght; i++)

{

digitalWrite(bell, HIGH);

delay(1000);

}

digitalWrite(bell, LOW);

i = 0;

}

}

delay(1000);

}

void over_ride()

{

lcd.clear();

while (Over_ride)

{

digitalWrite(bell, HIGH);

lcd.setCursor(0, 0);

lcd.print(“Press Exit to”);

lcd.setCursor(0, 1);

lcd.print(“Stop the bell?。。 保?

if (digitalRead(over_ride_off) == LOW)

{

Over_ride = false;

digitalWrite(bell, LOW);

}

}

Over_ride = true;

}

void bell_setting()

{

setting_value = 0;

EEPROM.write(setting_address, setting_value);

lcd.clear();

while (bell_status)

{

lcd.setCursor(0, 0);

lcd.print(“Bell is Disabled”);

lcd.setCursor(0, 1);

lcd.print(“Press Exit.”);

if (digitalRead(over_ride_off) == LOW)

{

bell_status = false;

}

}

bell_status = true;

setting_value = 1;

EEPROM.write(setting_address, setting_value);

}

//------------Program developed by R.GIRISH------------//

上傳上述代碼后,您應(yīng)該在顯示屏上看到以小時為單位的時間。

如何使用這個自動鈴鐺系統(tǒng):

在完成硬件設(shè)置后執(zhí)行此操作。

1.先上傳“時間設(shè)置”代碼,然后打開串行監(jiān)視器。

2.在主程序中設(shè)置需要觸發(fā)繼電器的時間 這里。

//---- 1st bell ------//

const int h1 = 0; //hours

const int m1 = 0; //Minutes

//---- 2nd bell ------//

const int h2 = 0;

const int m2 = 0;

//---- 3rd bell ------//

const int h3 = 0;

const int m3 = 0;

//---- 4th bell ------//

const int h4 = 0;

const int m4 = 0;

? 從 1 到 1 小時設(shè)置 h23(小時),在 1 到 0 之間設(shè)置 m59(以分鐘為單位)。

? 與 h1 至 h16 和 m1 至 m16 相同。

? 如果要禁用某些鈴鐺離開值 h = 0 和 m = 0,例如:h5 = 0 和 m5 = 0,則零將禁用該特定鈴鐺。

3.設(shè)置鈴鐺打開和關(guān)閉的時間長度,在這里:

---------------鐘聲長度(以秒為單位) -------//

const int Lenght = 3;以秒為單位

默認情況下,該值設(shè)置為 3 秒。當?shù)竭_設(shè)定的時間時,繼電器將打開 3 秒并關(guān)閉。如果需要,請更改此設(shè)置。

  1. 將修改后的代碼上傳到 Arduino。
  2. 要禁用鈴鐺,請按“鈴鐺禁用按鈕”。要重新啟用,請按“退出”按鈕。

6.要手動按鈴,請按“手動鈴開關(guān)”,要停止鈴聲,請按“退出”。

聲明:本文內(nèi)容及配圖由入駐作者撰寫或者入駐合作網(wǎng)站授權(quán)轉(zhuǎn)載。文章觀點僅代表作者本人,不代表電子發(fā)燒友網(wǎng)立場。文章及其配圖僅供工程師學習之用,如有內(nèi)容侵權(quán)或者其他違規(guī)問題,請聯(lián)系本站處理。 舉報投訴
  • 控制系統(tǒng)
    +關(guān)注

    關(guān)注

    41

    文章

    6419

    瀏覽量

    110094
  • Arduino
    +關(guān)注

    關(guān)注

    187

    文章

    6453

    瀏覽量

    185922
  • 實時時鐘模塊
    +關(guān)注

    關(guān)注

    0

    文章

    8

    瀏覽量

    1450
收藏 人收藏

    評論

    相關(guān)推薦

    基于Arduino構(gòu)建自動飲水機

    在這個項目中,我們將使用Arduino構(gòu)建自動飲水機和
    的頭像 發(fā)表于 11-09 16:22 ?2791次閱讀
    基于<b class='flag-5'>Arduino</b><b class='flag-5'>構(gòu)建</b><b class='flag-5'>一</b><b class='flag-5'>個</b><b class='flag-5'>自動</b>飲水機

    構(gòu)建基于Arduino自動寵物喂食器

    今天,我們正在構(gòu)建基于Arduino自動寵物喂食器,它可以及時自動為您的寵物提供食物。它有
    的頭像 發(fā)表于 11-17 17:28 ?2626次閱讀
    <b class='flag-5'>構(gòu)建</b><b class='flag-5'>一</b><b class='flag-5'>個</b>基于<b class='flag-5'>Arduino</b>的<b class='flag-5'>自動</b>寵物喂食器

    【項目分享】教你如何基于Arduino UNO設(shè)計聲控智能家居系統(tǒng)

    可以加入其中。如今許多智能家居系統(tǒng)的操控系統(tǒng)分為藍牙控制、互聯(lián)網(wǎng)控制、射頻控制和紅外控制等。每種
    發(fā)表于 09-25 18:12

    請問怎樣去設(shè)計種基于Arduino Nano的智能門禁控制系統(tǒng)

    基于Arduino Nano的智能門禁控制系統(tǒng)的硬件是怎樣構(gòu)成的?基于Arduino Nano的智能門禁控制系統(tǒng)的軟件模塊是怎樣構(gòu)成的?怎樣去設(shè)計
    發(fā)表于 08-23 07:15

    構(gòu)建自動控制系統(tǒng)

    控制系統(tǒng)。交付物是 Terrarium 控制器。在此過程中,您將學到很多有用的技術(shù),例如 Node-Red 編程環(huán)境和 MQTT。PCB 提供了 ESP32 Devkit,以及:
    發(fā)表于 07-25 07:15

    學校鈴聲定時電路圖

    學校鈴聲定時電路
    發(fā)表于 11-24 00:26 ?885次閱讀
    <b class='flag-5'>學校</b><b class='flag-5'>鈴聲</b>定時電路圖

    受電話鈴聲控制的臺燈電路圖

    受電話鈴聲控制的臺燈電路圖
    發(fā)表于 06-12 10:59 ?847次閱讀
    受電話<b class='flag-5'>鈴聲控制</b>的臺燈電路圖

    關(guān)于智能照明控制系統(tǒng)學校中的設(shè)計與應(yīng)用

    嚴格管理,仍不可避免地由于忘記關(guān)燈而造成巨大的能源浪費。為了達到節(jié)能優(yōu)化的控制效果,學校可采用智能照明控制系統(tǒng)來管理學校照明。智能照明控制系統(tǒng)
    發(fā)表于 05-12 14:35 ?1276次閱讀

    基于Arduino構(gòu)建簡單的家庭自動系統(tǒng)

    家庭自動系統(tǒng)日益普及,如今通過使用些簡單的控制機制(如繼電器或開關(guān))來打開和關(guān)閉某些設(shè)備變得很容易,我們之前使用繼電器構(gòu)建了許多基于
    發(fā)表于 08-08 16:04 ?1983次閱讀
    基于<b class='flag-5'>Arduino</b><b class='flag-5'>構(gòu)建</b><b class='flag-5'>一</b><b class='flag-5'>個</b>簡單的家庭<b class='flag-5'>自動</b>化<b class='flag-5'>系統(tǒng)</b>

    基于Arduino UNO的學校自動

    這個項目是學校自動鈴聲。當您想使用 Android 應(yīng)用程序時響鈴。
    發(fā)表于 12-09 11:31 ?0次下載

    智能照明控制系統(tǒng)學校中的應(yīng)用案例介紹

    ,仍不可避免地由于忘記關(guān)燈而造成巨大的能源浪費。為了達到節(jié)能優(yōu)化的控制效果,學校可采用智能照明控制系統(tǒng)來管理學校照明。智能照明控制系統(tǒng)與傳統(tǒng)
    的頭像 發(fā)表于 01-04 10:57 ?1631次閱讀
    智能照明<b class='flag-5'>控制系統(tǒng)</b>在<b class='flag-5'>學校</b>中的應(yīng)用案例介紹

    安科瑞智能照明控制系統(tǒng)學校的設(shè)計及應(yīng)用

    ,仍不可避免地由于忘記關(guān)燈而造成巨大的能源浪費。為了達到節(jié)能優(yōu)化的控制效果,學校可采用智能照明控制系統(tǒng)來管理學校照明。智能照明控制系統(tǒng)與傳統(tǒng)
    的頭像 發(fā)表于 05-16 13:48 ?459次閱讀
    安科瑞智能照明<b class='flag-5'>控制系統(tǒng)</b>在<b class='flag-5'>學校</b>的設(shè)計及應(yīng)用

    學校智能照明控制系統(tǒng)解決方案

    隨著科技的不斷發(fā)展,智能化已經(jīng)成為了各行各業(yè)的發(fā)展趨勢,而學校也不例外。智能照明控制系統(tǒng)種新型的智能化技術(shù),可對學校照明的自動
    的頭像 發(fā)表于 06-16 16:39 ?1330次閱讀

    構(gòu)建球和光束控制系統(tǒng)

    電子發(fā)燒友網(wǎng)站提供《構(gòu)建球和光束控制系統(tǒng).zip》資料免費下載
    發(fā)表于 06-29 10:05 ?0次下載
    <b class='flag-5'>構(gòu)建</b><b class='flag-5'>一</b><b class='flag-5'>個</b>球和光束<b class='flag-5'>控制系統(tǒng)</b>

    Arduino球和光束控制系統(tǒng)

    電子發(fā)燒友網(wǎng)站提供《Arduino球和光束控制系統(tǒng).zip》資料免費下載
    發(fā)表于 07-10 11:28 ?0次下載
    <b class='flag-5'>Arduino</b>球和光束<b class='flag-5'>控制系統(tǒng)</b>