Andy Fundinger
Published © GPL3+

The First Clock of February

This then is the first clock of February, a ChipKIT Uno32 with a ChipKIT Basic I/O Shield attached.

BeginnerFull instructions provided587
The First Clock of February

Things used in this project

Hardware components

Microchip Digilent ChipKit Uno32
×1
32768Hz Crystal
×1
chipKIT Basic I/O Shield
×1

Software apps and online services

Microchip Multi Platform IDE (for chipKit)

Hand tools and fabrication machines

Soldering iron (generic)
Soldering iron (generic)

Story

Read more

Code

OLED_Clock.pde

C/C++
Program the chipKit using the MPIDE
/* OLED_Clock */
/* Author:  Andy Fundinger */
/* Copyright 2013 */ 

/* Contains code from: */
/*  IOShieldOled.c  --  OLED Display Driver for Basic I/O Shield        */
/*  Author: 	Oliver Jones						*/
/*  Copyright 2011, Digilent Inc.					*/

/*  RTCCDemo.c  */
/*  copyright 2011 Majenko Technologies. */

/*
  This program is free software; you can redistribute it and/or
  modify it under the terms of the GNU Lesser General Public
  License as published by the Free Software Foundation; either
  version 2.1 of the License, or (at your option) any later version.

  This library is distributed in the hope that it will be useful,
  but WITHOUT ANY WARRANTY; without even the implied warranty of
  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
  Lesser General Public License for more details.

  You should have received a copy of the GNU Lesser General Public
  License along with this library; if not, write to the Free Software
  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
*/


#include <IOShieldOled.h>
#include <RTCC.h>

#define SET_1    4 
#define SET_2   34 
#define SET_3   36
#define SET_4   37

void setup()
{
  IOShieldOled.begin();
  Serial.begin(9600);

  // Initialize the RTCC module
  RTCC.begin();
  
  // Set the time to something sensible
  RTCC.hours(11);
  RTCC.minutes(45);
  RTCC.seconds(0);
  RTCC.year(13);
  RTCC.month(01);
  RTCC.day(29);
  pinMode(SET_1, INPUT);
  pinMode(SET_2, INPUT);
  pinMode(SET_3, INPUT);
  pinMode(SET_4, INPUT);     
}

void loop()
{
  int irow;
  
  char date[9];
  char time[9];
  
  // Format the time and print it.
  sprintf(date,"%02d/%02d/%02d", 
    RTCC.month(),    
    RTCC.day(),
    RTCC.year()
  );
  sprintf(time,"%02d:%02d:%02d",
    RTCC.hours(),
    RTCC.minutes(),
    RTCC.seconds()
  );

  //Clear the virtual buffer
  IOShieldOled.clearBuffer();
  
  //Chosing Fill pattern 0
  IOShieldOled.setFillPattern(IOShieldOled.getStdPattern(0));
  //Turn automatic updating off
  IOShieldOled.setCharUpdate(0);
  
  //Draw a rectangle over wrting then slide the rectagle
  //down slowly displaying all writing
//  for (irow = 0; irow < IOShieldOled.rowMax; irow++)
//  {
    IOShieldOled.clearBuffer();
    IOShieldOled.setCursor(0, 0);
    IOShieldOled.putString(date);
    IOShieldOled.setCursor(0, 1);
    IOShieldOled.putString(time);
    IOShieldOled.setCursor(0, 2);
    IOShieldOled.putString("MakerBar");
    IOShieldOled.setCursor(0, 3);
    IOShieldOled.putString("ChipKit Clock");
    
//    IOShieldOled.moveTo(0, irow);
//    IOShieldOled.drawFillRect(127,31);
//    IOShieldOled.moveTo(0, irow);
//    IOShieldOled.drawLine(127,irow);
    IOShieldOled.updateDisplay();
//    delay(100);
//  }
  
    if (digitalRead(SET_1)){
      RTCC.minutes(RTCC.minutes()+1);
      RTCC.seconds(0);
    }
    if (digitalRead(SET_2)){
      RTCC.hours(RTCC.hours()+1);
      RTCC.seconds(0);
    }
    if (digitalRead(SET_3)){
      RTCC.day(RTCC.day()+1);
    }
    if (digitalRead(SET_4)){
      RTCC.month(RTCC.month()+1);
    }
    if (digitalRead(SET_1)|digitalRead(SET_2)|digitalRead(SET_3)|digitalRead(SET_4)){
      delay(300);
    }
  
//  delay(1000);
}

Credits

Andy Fundinger

Andy Fundinger

1 project • 0 followers
Python Developer in the Financial Industry and member of the MakerBar in Hoboken.

Comments