Arduino-MP3 Shield for Dynamic Music Alarm


Mencoba mengingat kembali pemrograman mikrokontroler, kali ini menggunakan arduino yang diembeded dengan MP3 Shield. berikut program yang diload ke arduino

#include
#include
#include
#include

int led=8;
LiquidCrystal lcd(12, 11, 10, 5, 4, 3, 2);
int backLight = 13;

String comdata = “”;
int mark=0;
//store the current time data
int rtc[7];
//store the set time data
byte rr[7];
//light pin
int ledPin = 13;
//initial light

boolean temp=0;
void setup()
{
Serial.begin(9600);
pinMode(2, INPUT);
pinMode(3, INPUT);
pinMode(4, INPUT);
pinMode(backLight, OUTPUT);
digitalWrite(backLight,

HIGH); // turn backlight on. Replace ‘HIGH’

with ‘LOW’ to turn it off.
lcd.begin(16,2);

// columns, rows. use 16,2 for a 16×2 LCD,
etc.
lcd.clear();
// start with a blank screen
lcd.setCursor(0,0);
// set cursor to column 0, row 0 (the first
row)
lcd.print(” ESC Tel-U
“); // change this text to whatever you
like. keep it clean.
lcd.setCursor(0,1);
// set cursor to column 0, row 1
lcd.print(” The Monument “);
delay(1000);

DDRC |= _BV(2) | _BV(3); // POWER:Vcc Gnd
PORTC |= _BV(3); // VCC PINC3
pinMode(ledPin, OUTPUT);
//initial baudrate
Serial.begin(9600);
//get current time
RTC.get(rtc, true);
//if time is wrong reset to default time
if (rtc[6] < 2015) {
//stop rtc time
RTC.stop();
RTC.set(DS1307_SEC, 0);
RTC.set(DS1307_MIN, 0);
RTC.set(DS1307_HR, 0);
RTC.set(DS1307_DOW, 1);
RTC.set(DS1307_DATE, 1);
RTC.set(DS1307_MTH, 1);
RTC.set(DS1307_YR, 15);
//start rtc time
RTC.start();
}
//RTC.SetOutput(LOW);
//RTC.SetOutput(HIGH);
//RTC.SetOutput(DS1307_SQW1HZ);
//RTC.SetOutput(DS1307_SQW4KHZ);
//RTC.SetOutput(DS1307_SQW8KHZ);
RTC.SetOutput(DS1307_SQW32KHZ);
lcd.clear();

music.init();
delay(1000);
//music.power(ON);
delay(200);
music.power(OFF);
delay(100);
}

void loop(){
int i;
RTC.get(rtc, true);
lcd.setCursor(0,0);
int dow = rtc[3];
switch(dow){
case 1:
lcd.print("Senin ");
break;
case 2:
lcd.print("Selasa");
break;
case 3:
lcd.print("Rabu ");
break;
case 4:
lcd.print("Kamis ");
break;
case 5:
lcd.print("Jumat ");
break;
case 6:
lcd.print("Sabtu ");
break;
case 0:
lcd.print("Minggu");
break;
}
lcd.setCursor(8,0);
lcd.print(rtc[4]);
lcd.print("/");
lcd.print(rtc[5]);
lcd.print("/");
lcd.print(rtc[6]-2000);
lcd.setCursor(8,1);
if (rtc[2] < 10) {
lcd.print("0");
}
lcd.print(rtc[2]);
lcd.print(":");
if (rtc[1] < 10) {
lcd.print("0");
}
lcd.print(rtc[1]);
lcd.print(":");
if (rtc[0] =0&&rtc[0]

=0&&rtc[0]=0&&rtc[0]=0&&rtc[0]=0&&rtc[0]=0&&rtc

[0]=0&&rtc[0]=0&&rtc[0]=0&&rtc[0]=0&&rtc[0]=0&&rtc[0]=0&&rtc[0]=0&&rtc

[0]=0&&rtc[0]=0&&rtc[0]

=0&&rtc[0]=0&&rtc[0]=0&&rtc[0]=0&&rtc

[0]=0&&rtc[0]=0&&rtc[0]=0&&rtc[0]=0&&rtc[0]=0&&rtc[0]=0&&rtc[0]=0&&rtc[0]=0&&rtc[0]=0&&rtc[0]=0&&rtc[0]=0&&rtc[0]=0&&rtc[0]=0&&rtc[0]=0&&rtc[0]=0&&rtc[0]=0&&rtc[0]=0&&rtc[0]=0&&rtc[0]=0&&rtc[0]=0&&rtc[0]=0&&rtc[0]=0&&rtc[0]=0&&rtc[0]=0&&rtc[0]=0&&rtc[0]=0&&rtc[0]=0&&rtc[0]=0&&rtc[0]=0&&rtc[0]=0&&rtc[0]=0&&rtc[0]=0&&rtc[0]=0&&rtc[0]<=1)&&temp)
{
music.pause();
delay(200);
music.next();
delay(100);
music.power(OFF);
delay(100);
lcd.setCursor(0,1);
lcd.print("9 off");
temp=0;
}
else
{
//lcd.setCursor(0,1);
//lcd.print("else ");
}

}


Leave a Reply

Your email address will not be published. Required fields are marked *