A sunrise alarm clock controlled through serial designed to run on a LPC 1768 and is currently being modified to run on a Nucleo board

Dependencies:   RTC mbed

main.cpp

Committer:
propellerhead
Date:
2015-08-05
Revision:
0:ea21a4715fed
Child:
1:dcd847fa6def

File content as of revision 0:ea21a4715fed:

#include "mbed.h"

PwmOut reds(p21);
PwmOut greens(p22);
PwmOut yellows(p23);
PwmOut blues(p24);

Serial pc(USBTX, USBRX);

void Rx_interrupt(void);

int main(){
    pc.baud(9600);
    reds.period_ms(1);
    greens.period_ms(1);
    yellows.period_ms(1);
    blues.period_ms(1);
    
    reds.pulsewidth_us(500);
    greens.pulsewidth_us(500);
    yellows.pulsewidth_us(500);
    blues.pulsewidth_us(500);
    
    pc.attach(&Rx_interrupt, Serial::RxIrq);
    
    set_time(1256729737);  // Set RTC time to Wed, 28 Oct 2009 11:35:37

    while(1) {
        time_t seconds = time(NULL);
        seconds.

        printf("Time as seconds since January 1, 1970 = %d\r\n", seconds);

        printf("Time as a basic string = %s\r\n", ctime(&seconds));

        char buffer[32];
        strftime(buffer, 32, "%I:%M %p\r\n", localtime(&seconds));
        printf("Time as a custom formatted string = %s\r\n", buffer);

        wait(1);
    }
    
    return 0;
}

void Rx_interrupt(){
        
}