Cara Membuat Alarm Repeat Dengan Arduino Uno

Pembuatan Alarm Digital dengan menggunakan Arduino uno sangat mudah dibuat, dengan menggunakan library "TimeAlarm"kita bisa membuat Alarm Repeat dengan Mudah. Sebelum kita membuat alarm repeat dengan arduino, sebaiknya kita download dulu library "TimeAlarm", untuk Library TimeAlarm Bisa di download DISINI.
Setelah Library TimeAlarm di download, kemudian dicopy pada libraries arduino : C:\Program File\Arduino\Libraries. Setelah semuanya dicopy maka di software Arduino akan ada menu TimeAlarm di menu examples seperti gambar dibawah :


Menu TimeAlarm Example di clik maka akan muncul coding seperti dibawah :

 /*
 * TimeAlarmExample.pde
 *
 * This example calls alarm functions at 8:30 am and at 5:45 pm (17:45)
 * and simulates turning lights on at night and off in the morning
 * A weekly timer is set for Saturdays at 8:30:30
 *
 * A timer is called every 15 seconds
 * Another timer is called once only after 10 seconds
 *
 * At startup the time is set to Jan 1 2011  8:29 am
 */

#include <TimeLib.h>
#include <TimeAlarms.h>

void setup()
{
  Serial.begin(9600);
  setTime(8,29,0,1,1,11); // set time to Saturday 8:29:00am Jan 1 2011
  // create the alarms
  Alarm.alarmRepeat(8,30,0, MorningAlarm);  // 8:30am every day
  Alarm.alarmRepeat(17,45,0,EveningAlarm);  // 5:45pm every day
  Alarm.alarmRepeat(dowSaturday,8,30,30,WeeklyAlarm);  // 8:30:30 every Saturday


  Alarm.timerRepeat(15, Repeats);            // timer for every 15 seconds  
  Alarm.timerOnce(10, OnceOnly);             // called once after 10 seconds
}

void  loop(){
  digitalClockDisplay();
  Alarm.delay(1000); // wait one second between clock display
}

// functions to be called when an alarm triggers:
void MorningAlarm(){
  Serial.println("Alarm: - turn lights off");  
}

void EveningAlarm(){
  Serial.println("Alarm: - turn lights on");         
}

void WeeklyAlarm(){
  Serial.println("Alarm: - its Monday Morning");    
}

void ExplicitAlarm(){
  Serial.println("Alarm: - this triggers only at the given date and time");     
}

void Repeats(){
  Serial.println("15 second timer");       
}

void OnceOnly(){
  Serial.println("This timer only triggers once");
}

void digitalClockDisplay()
{
  // digital clock display of the time
  Serial.print(hour());
  printDigits(minute());
  printDigits(second());
  Serial.println();
}

void printDigits(int digits)
{
  Serial.print(":");
  if(digits < 10)
    Serial.print('0');
  Serial.print(digits);
}


 di coding ini bisa kita rubah rubah jumlah repeat, jam, hari untuk alarmnya, silakan mencoba, semoga sedikit paparan ini bisa bermanfaat. selamat mencoba.







 

Komentar