Seeking guidance with project.

Greetings.

I am in need of guidance regarding a project.

Overview:

I am wanting to build an alarm clock that will activate according to a timetable specified and play an audio file. Both the time table and audio file to be stored on a micro sd card. The LCD should display current time (first line) as well as "current alarm name" (second line)

I have the nano v3 that I would like to connect a 16x2 LCD, DS1302, micro SD card reader and small speaker to. I am able to connect each component individually but I need them all to work together.

If anyone can please offer me some assistance in completing this task it would be greatly appreciated.

Regards M.

I am able to connect each component individually but I need them all to work together.

So what is stopping you from doing this?

Just take the individual code that drives each device and put it into a function. Then call the functions in the order you want.

I dont see anything in your 'list' that will allow you play audio (of any kind.. outside of maybe a TONE)?

I see no DAC, AMP..etc.. mentioned? (what am I missing?)

If you plan on playing a .wav file (or whatever) directly from the SD card, using SimpleAudioPlayer or something similar.. you still need an AMP to make sure you can hear it loud enough.

Grumpy_Mike: So what is stopping you from doing this?

Just take the individual code that drives each device and put it into a function. Then call the functions in the order you want.

Thank you for your response. I have little to zero knowledge of arduino and I am busy learning as I go. I imagined that you could insert code into multiple tabs and then compile them all as one, but I do not know how to do this, do you perhaps know where I can find this info?

Regards MCD

xl97: I dont see anything in your 'list' that will allow you play audio (of any kind.. outside of maybe a TONE)?

I see no DAC, AMP..etc.. mentioned? (what am I missing?)

If you plan on playing a .wav file (or whatever) directly from the SD card, using SimpleAudioPlayer or something similar.. you still need an AMP to make sure you can hear it loud enough.

Thank you for your response. I have little to zero understanding of this and I am busy learning as I go. Is there a tutorial or thread where I can find information regarding playing an audio file from sd card using nano v3.

Regards MCD

So far I have connected the lcd and the ds1302 to the nano v3, however the lcd is displaying hello world and counting duration active on the second line.

I have run the SetTime for the RTC DS1302 and have my current time set a write protected on the RTC.

When I open the serial command the time is displayed in a format I do not want.


UNIX Time: 1469801052 Time = 14:04:12, Date (D/M/Y) = 29/7/2016, DoW = 6


I would prefer to just have the current time and date in the most simple format on the first line of the LCD displayed.

The format I want.


HH:MM - DD/MM/YYYY


This is my code the i am using so far.

  LiquidCrystal Library - Hello World

 Demonstrates the use a 16x2 LCD display.  The LiquidCrystal
 library works with all LCD displays that are compatible with the
 Hitachi HD44780 driver. There are many of them out there, and you
 can usually tell them by the 16-pin interface.

 This sketch prints "Hello World!" to the LCD
 and shows the time.

  The circuit:
 * LCD RS pin to digital pin 12
 * LCD Enable pin to digital pin 11
 * LCD D4 pin to digital pin 5
 * LCD D5 pin to digital pin 4
 * LCD D6 pin to digital pin 3
 * LCD D7 pin to digital pin 2
 * LCD R/W pin to ground
 * LCD VSS pin to ground
 * LCD VCC pin to 5V
 * 10K resistor:
 * ends to +5V and ground
 * wiper to LCD VO pin (pin 3)

 Library originally added 18 Apr 2008
 by David A. Mellis
 library modified 5 Jul 2009
 by Limor Fried (http://www.ladyada.net)
 example added 9 Jul 2009
 by Tom Igoe
 modified 22 Nov 2010
 by Tom Igoe

 This example code is in the public domain.

 http://www.arduino.cc/en/Tutorial/LiquidCrystal
 */

// include the library code:
#include <LiquidCrystal.h>
#include <Time.h>
#include <DS1302RTC.h>

// Set pins:  CE, IO,CLK
DS1302RTC RTC(13, 10, 9);

// Optional connection for RTC module
#define DS1302_GND_PIN 33
#define DS1302_VCC_PIN 35

// initialize the library with the numbers of the interface pins
LiquidCrystal lcd(12, 11, 5, 4, 3, 2);

void setup() {
  // set up the LCD's number of columns and rows:
  lcd.begin(16, 2);
  // Print a message to the LCD.
  lcd.print("hello, world!");



  // Setup Serial connection
  Serial.begin(9600);
  
  Serial.println("DS1302RTC Read Test");
  Serial.println("-------------------");
  
  // Activate RTC module
  digitalWrite(DS1302_GND_PIN, LOW);
  pinMode(DS1302_GND_PIN, OUTPUT);

  digitalWrite(DS1302_VCC_PIN, HIGH);
  pinMode(DS1302_VCC_PIN, OUTPUT);
  
  Serial.println("RTC module activated");
  Serial.println();
  delay(500);
  
  if (RTC.haltRTC()) {
    Serial.println("The DS1302 is stopped.  Please run the SetTime");
    Serial.println("example to initialize the time and begin running.");
    Serial.println();
  }
  if (!RTC.writeEN()) {
    Serial.println("The DS1302 is write protected. This normal.");
    Serial.println();
  }
  
  delay(5000);
}

void loop() {
  // set the cursor to column 0, line 1
  // (note: line 1 is the second row, since counting begins with 0):
  lcd.setCursor(0, 1);
  // print the number of seconds since reset:
  lcd.print(millis() / 1000);


  tmElements_t tm;
  
  Serial.print("UNIX Time: ");
  Serial.print(RTC.get());

  if (! RTC.read(tm)) {
    Serial.print("  Time = ");
    print2digits(tm.Hour);
    Serial.write(':');
    print2digits(tm.Minute);
    Serial.write(':');
    print2digits(tm.Second);
    Serial.print(", Date (D/M/Y) = ");
    Serial.print(tm.Day);
    Serial.write('/');
    Serial.print(tm.Month);
    Serial.write('/');
    Serial.print(tmYearToCalendar(tm.Year));
    Serial.print(", DoW = ");
    Serial.print(tm.Wday);
    Serial.println();
  } else {
    Serial.println("DS1302 read error!  Please check the circuitry.");
    Serial.println();
    delay(9000);
  }
  
  // Wait one second before repeating :)
  delay (1000);
}

void print2digits(int number) {
  if (number >= 0 && number < 10)
    Serial.write('0');
  Serial.print(number);
}

/*

Your help is most appreciated

Regards
MCD

UPDATE.

( I am using the nano v3 by the way.)

I have edited the output format of my time as I require.

My code is below.
Can someone please indicate how I get the serial output of the RTC to display on the LCD line 0

/

/ include the library code:

#include <LiquidCrystal.h>
#include <Time.h>
#include <DS1302RTC.h>

// Set pins:  CE, IO,CLK
DS1302RTC RTC(13, 10, 9);

// Optional connection for RTC module
#define DS1302_GND_PIN 33
#define DS1302_VCC_PIN 35

// initialize the library with the numbers of the interface pins
LiquidCrystal lcd(12, 11, 5, 4, 3, 2);

void setup() {
  // set up the LCD's number of columns and rows:
  lcd.begin(16, 2);
  // Print a message to the LCD.
  lcd.print("hello, world!");



  // Setup Serial connection
  Serial.begin(9600);
  
  Serial.println("DS1302RTC Read Test");
  Serial.println("-------------------");
  
  // Activate RTC module
  digitalWrite(DS1302_GND_PIN, LOW);
  pinMode(DS1302_GND_PIN, OUTPUT);

  digitalWrite(DS1302_VCC_PIN, HIGH);
  pinMode(DS1302_VCC_PIN, OUTPUT);
  
  Serial.println("RTC module activated");
  Serial.println();
  delay(500);
  
  if (RTC.haltRTC()) {
    Serial.println("The DS1302 is stopped.  Please run the SetTime");
    Serial.println("example to initialize the time and begin running.");
    Serial.println();
  }
  if (!RTC.writeEN()) {
    Serial.println("The DS1302 is write protected. This normal.");
    Serial.println();
  }
  
  delay(5000);
}

void loop() {
  // set the cursor to column 0, line 1
  // (note: line 1 is the second row, since counting begins with 0):
  lcd.setCursor(0, 1);
  // print the number of seconds since reset:
  lcd.print(millis() / 1000);


  tmElements_t tm;
  


  if (! RTC.read(tm)) {
    
    print2digits(tm.Hour);
    Serial.write(':');
    print2digits(tm.Minute);
    Serial.write(':');
    print2digits(tm.Second);
    Serial.print(" ");    
    Serial.print(tm.Day);
    Serial.write('/');
    Serial.print(tm.Month);
    Serial.write('/');
    Serial.print(tmYearToCalendar(tm.Year));
    Serial.println();
  } else {
    Serial.println("DS1302 read error!  Please check the circuitry.");
    Serial.println();
    delay(9000);
  }
  
  // Wait one second before repeating :)
  delay (1000);
}

void print2digits(int number) {
  if (number >= 0 && number < 10)
    Serial.write('0');
  Serial.print(number);
}

You put the words

Arduino DS1302RTC libiary

into the search box of google You then click the first link returned which is

http://playground.arduino.cc/Main/DS1302RTC

Grumpy_Mike: You put the words

Arduino DS1302RTC libiary

into the search box of google You then click the first link returned which is

http://playground.arduino.cc/Main/DS1302RTC

Thank you for your help. It is most appreciated.

Hi there

I have sd card, lcd and rtc ds1302 successfully connected and working.

Here is my code below.

I would like to now know if anyone can please point me in the direction of how to play a .wav/mp3 file from the sd card according to a .csv timetable stored on the sd card aswell.

Thank you for your assistance.

Regards
MCD

#include <SPI.h>
#include <SD.h>

File myFile;

#include <LiquidCrystal.h>
#include <DS1302RTC.h>
#include <Time.h>

// Init the DS1302
// Set pins:  CE, IO,CLK
DS1302RTC RTC(6, 10, 9);

// Optional connection for RTC module
#define DS1302_GND_PIN 33
#define DS1302_VCC_PIN 35

// Init the LCD
//   initialize the library with the numbers of the interface pins
//            lcd(RS,  E, d4, d5, d6, d7)
LiquidCrystal lcd(7, 8, 5, A0, 3, 2);

////////////////////////////////////////////////////////////////////////

void setup()
{
  // Setup LCD to 16x2 characters
  lcd.begin(16, 2);
////////////////////////////////////////////////////////////////////////
  // Activate RTC module
  digitalWrite(DS1302_GND_PIN, LOW);
  pinMode(DS1302_GND_PIN, OUTPUT);

  digitalWrite(DS1302_VCC_PIN, HIGH);
  pinMode(DS1302_VCC_PIN, OUTPUT);

  lcd.print("RTC activated");

  delay(500);

  // Check clock oscillation  
  lcd.clear();
  if (RTC.haltRTC())
    lcd.print("Clock stopped!");
  else
    lcd.print("Clock working.");

  // Check write-protection
  lcd.setCursor(0,1);
  if (RTC.writeEN())
    lcd.print("Write allowed.");
  else
    lcd.print("Write protected.");

  delay ( 2000 );

  // Setup Time library  
  lcd.clear();
  lcd.print("RTC Sync");
  setSyncProvider(RTC.get); // the function to get the time from the RTC
  if(timeStatus() == timeSet)
    lcd.print(" Ok!");
  else
    lcd.print(" FAIL!");

  delay ( 2000 );

  lcd.clear();

////////////////////////////////////////////////////////////////////////
  
  {
  // Open serial communications and wait for port to open:
  Serial.begin(9600);
  while (!Serial) {
    ; // wait for serial port to connect. Needed for native USB port only
  }


  Serial.print("Initializing SD card...");

  if (!SD.begin(4)) {
    Serial.println("initialization failed!");
    return;
  }
  Serial.println("initialization done.");

  // open the file. note that only one file can be open at a time,
  // so you have to close this one before opening another.
  myFile = SD.open("test.txt", FILE_WRITE);

  // if the file opened okay, write to it:
  if (myFile) {
    Serial.print("Writing to test.txt...");
    myFile.println("testing 1, 2, 3.");
    // close the file:
    myFile.close();
    Serial.println("done.");
  } else {
    // if the file didn't open, print an error:
    Serial.println("error opening test.txt");
  }

  // re-open the file for reading:
  myFile = SD.open("test.txt");
  if (myFile) {
    Serial.println("test.txt:");

    // read from the file until there's nothing else in it:
    while (myFile.available()) {
      Serial.write(myFile.read());
    }
    // close the file:
    myFile.close();
  } else {
    // if the file didn't open, print an error:
    Serial.println("error opening test.txt");
  }
}

}
  ////////////////////////////////////////////////////////////////////////

void loop()
{
  ////////////////////////////////////////////////////////////////////////
  // Display the current prayer name - left alignment on the upper line
  lcd.setCursor(0, 0);
  print2digits(hour());
  lcd.print(":");
  print2digits(minute());
  lcd.print(":");
  print2digits(second());
  ////////////////////////////////////////////////////////////////////////

  ////////////////////////////////////////////////////////////////////////
  // Display time centered on the upper line
  lcd.setCursor(8, 0);
  print2digits(hour());
  lcd.print(":");
  print2digits(minute());
  lcd.print(":");
  print2digits(second());
  ////////////////////////////////////////////////////////////////////////
  // Display abbreviated Day-of-Week in the lower left corner
  lcd.setCursor(0, 1);
  lcd.print(dayShortStr(weekday()));
  ////////////////////////////////////////////////////////////////////////
  // Display date in the lower right corner
  lcd.setCursor(5, 1);
  lcd.print(" ");
  print2digits(day());
  lcd.print("/");
  print2digits(month());
  lcd.print("/");
  lcd.print(year());
  ////////////////////////////////////////////////////////////////////////
  // Warning!
  if(timeStatus() != timeSet) {
    lcd.setCursor(0, 1);
    lcd.print(F("RTC ERROR: SYNC!"));
  }

  delay ( 1000 ); // Wait approx 1 sec
}

void print2digits(int number) {
  // Output leading zero
  if (number >= 0 && number < 10) {
    lcd.write('0');
  }
  lcd.print(number);
}

point me in the direction of how to play a .wav/mp3 file from the sd card according to a .csv timetable stored on the sd card aswell.

Wow that is some leap in complexity.

It is rather advanced and I would strongly suggest you get experience writing code before you tackle something like this.

Basically you can only play an MP3 file if you have an off board chip, and these normally come with their own SD cards so you can't access other files on them. A .wav file can be played off a normal SD card, you can use a commercial kit from AdaFruit or you can use their open source circuit and make your own.

As to the last part, this is the most complex because it involves two things:- 1) defining a rigid .cvs file format to use, prefrably in time stamp order. 2) reading that file from the SD card and parsing the data from it to find what to play when. You would also the real time clock chip to give you an absolute time reference.