xx16 display +tmp102 +speaker

Dependencies:   TextLCD mbed TMP102

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers main.cpp Source File

main.cpp

00001 // Hello World! for the TextLCD
00002 
00003 #include "mbed.h"
00004 #include "TextLCD.h"
00005 #include "TMP102.h"
00006 
00007 DigitalOut blue_led(LED1);
00008 DigitalOut speaker(p21);
00009 
00010 TMP102 temperature(p9, p10, 0x92); //A0 pin is connected to ground
00011 TextLCD lcd(p15, p16, p17, p18, p19, p20); // rs, e, d4-d7
00012 
00013 int main() {
00014     
00015     char buffer[32];
00016     time_t seconds = time(NULL);
00017     
00018     set_time(1256729737);
00019     printf("%s\n", buffer);
00020     lcd.cls();
00021     for (int i = 0 ; i <= 100 ; i += 1 )
00022     {
00023         speaker = !speaker;
00024         wait (0.001); // 5kHz, with 10 steps
00025     }
00026     for (int i = 0 ; i <= 50 ; i += 1 )
00027     {
00028         speaker = !speaker;
00029         wait (0.002); // 5kHz, with 10 steps
00030     }
00031     
00032     
00033     while(1)
00034     {
00035         lcd.cls();
00036         seconds = time(NULL);
00037         strftime(buffer, 32, "%X", localtime(&seconds));
00038         lcd.printf("%s\n", buffer);
00039         //printf("%s\n", buffer);
00040         lcd.printf("Temp: %f\n", temperature.read());
00041         blue_led = 1;
00042         wait(0.5);
00043         blue_led = 0;
00044         wait(0.5);
00045     }
00046     
00047     //while (1)
00048     //{
00049     //     speaker = !speaker;
00050     //     wait (0.001); // 5kHz
00051     //}
00052     
00053     
00054 }