WSPR: Arduni DS1302 Timer - LED Monitor Status

From OnnoWiki
Jump to navigation Jump to search

Code

// time RTC sync
// pin PIN_AUD - kuning - audio SD
// pin PIN_PTT  - merah  - PTT
// pin PIN_SYN  - hijau  - NTP sync
//
// file WAV WSPR diambil dari rekaman wsjt-x

#include <Time.h>
#include "TMRpcm.h"
#include <SD.h>
#include <DS1302.h>

// Init the DS1302
// DS1302 rtc([CE/RST], [I/O], [CLOCK]);
DS1302 rtc(8, 7, 6);
Time waktu;

const int CS_PIN  = 4;
const int PIN_AUD = 13;
const int PIN_PTT = 1;
TMRpcm audio;

void setup() {
  pinMode(PIN_AUD, OUTPUT);  // LED kuning - blinking audio OK
  pinMode(PIN_PTT, OUTPUT);  // LED merah  - PTT ON
  digitalWrite(PIN_AUD, LOW);
  digitalWrite(PIN_PTT, LOW);

  // Set the clock to run-mode, and disable the write protection
  rtc.halt(false);
  rtc.writeProtect(true);
  
  audio.speakerPin = 9;
  audio.setVolume(3);
  pinMode(CS_PIN, OUTPUT);
  if (!SD.begin(CS_PIN)) digitalWrite(PIN_AUD, HIGH);
}

void loop() {
  waktu = rtc.getTime();
  // int dataJam = waktu.hour;     
  // int dataMenit = waktu.min;
  // int dataDetik = waktu.sec;
  
  if(audio.isPlaying()==0) digitalWrite(PIN_PTT, LOW);
    else digitalWrite(PIN_PTT, HIGH);
    
  if( waktu.min==0 )
    if(audio.isPlaying()==0) {
      if (!SD.begin(CS_PIN)) digitalWrite(PIN_AUD, HIGH);
      digitalWrite(PIN_PTT, HIGH);
      audio.play("YC0MLC.WAV");
      delay(90L*1000);
      }
  if( waktu.min==30 )
    if(audio.isPlaying()==0) {
      if (!SD.begin(CS_PIN)) digitalWrite(PIN_AUD, HIGH);
      digitalWrite(PIN_PTT, HIGH);
      audio.play("YC0MLC.WAV");
      delay(90L*1000);
      }
  delay(10*1000);
}