Difference between revisions of "MClock (X02)"

From Microduino Wiki
Jump to: navigation, search
(Tweaking)
(Program)
Line 20: Line 20:
 
1. Connect [[mCookie-Core|mCookie Core]] to the PC with the USB Cable. Open the Microduino IDE.
 
1. Connect [[mCookie-Core|mCookie Core]] to the PC with the USB Cable. Open the Microduino IDE.
  
2. Copy and paste the code below and upload.
+
2. Download the project file and unzip: '''<big>[[File:mClock_X02.zip]]</big>'''.
 
+
*Using the Microduino IDE and go to '''File > Open...''' and navigate to the unzipped folder. Open the '''mClock_X02.ino''' file.
<source lang="cpp">
 
 
 
</source>
 
  
 
3. Find this code section and set the initial time of the RTC module.  
 
3. Find this code section and set the initial time of the RTC module.  

Revision as of 19:31, 6 April 2017

File:MClock Project.jpg
mClock Project Build

About

This project uses the Real Time Clock (RTC) module to keep track of time. The time is retrieved from the RTC module and displayed on an OLED module. This project is an adaptation of the MWatch project from the first generation mCookie Maker Kits.

This project was designed for the second generation mCookie Maker kits (202 Advanced and 302 Expert kits).

Required Materials

  • 1 x mCookie Core
  • 1 x mBattery (202/302 Kit)
  • 1 x Real Time Clock (RTC) Module
  • 1x mCookie OLED Module
  • 1 x MicroUSB Cable

Build

Assembly

  1. Stack all three of the modules, mCookie Core, mCookie RTC, and mCookie OLED onto mBattery. Ensure that mCookie OLED is on top of the stack.
  2. Plug in the MicroUSB cable to the mBattery to a computer.

Program

1. Connect mCookie Core to the PC with the USB Cable. Open the Microduino IDE.

2. Download the project file and unzip: File:MClock X02.zip.

  • Using the Microduino IDE and go to File > Open... and navigate to the unzipped folder. Open the mClock_X02.ino file.

3. Find this code section and set the initial time of the RTC module.

setRtcTime(15, 5, 18, 1, 00, 00, 00);

The function signature is as follows: setRtcTime(year, month, day, week, hour, minute, sec);.

Replace the value of the time you wish to set. Once set, the module will maintain the time even when the power is off.

4. Select the board, processor and port:

  • Go to Tools > Board and select Microduino/mCookie-Core (328p)
  • Go to Tools > Processor and select Atmega328P16M,5V
  • Go to Tools > Port and select the available port

NOTE: If not using the default Core module included in the kits, please follow the selecting the board and processor guide.

5. Upload the program by clicking on the right arrow icon on the top left of the window. Or under Sketch > Upload.

6. Once the program is uploaded. The line of code in step number 3 will set the time on the Real Time Clock module. But this occurs every time the Core module starts up. Which is undesired in keep track of the time. Go back to the code and disable that line by commenting it out with // as follows. Then re-upload the program.

//setRtcTime(15, 5, 18, 1, 00, 00, 00);

Debugging

Tweaking

Usage

Turn on the project and the time stored on the Real Time Clock (RTC) module will be retrieved and displayed on the OLED screen. Powering off the project will maintain the time since the Real Time Clock (RTC) has a capacitor that enables keeping track of the time even when the power source is off. (Please comment out the setRtcTime line so that the time does not get overwritten every time the Core module starts up).