This program displays a series of text messages on a 16x2 line LCD and also then displays the room temperature taken from a TMP102 I2C module. It represents my first attempt to do anything useful with an mbed which is something I got my hands on less than 4 days ago. It shows what can be achieved by someone who has no prior knowledge of C after about 4 hours of tinkering with various sample programs. This code itself took me around 40 minutes of that 4 hours of play time to craft. The LCD is hooked up to the mbed as per the TextLCD program instructions. The TMP102 module is hooked up as per the TMP102HelloWorld program instructions. If you want to hook up some of the more complex components in your Cool Components starter kit and see them work in a matter of minutes, this little showcase program will do just that. Enjoy. Thanks to whoever wrote the libraries and original code which I used.

Dependencies:   TextLCD mbed TMP102

main.cpp

Committer:
bigweggy
Date:
2012-04-21
Revision:
0:9f9af3710502

File content as of revision 0:9f9af3710502:

// Hello World! for the TextLCD

#include "mbed.h"
#include "TextLCD.h"
#include "TMP102.h"

TextLCD lcd(p15, p16, p17, p18, p19, p20); // rs, e, d4-d7
TMP102 temperature(p9, p10, 0x90); //A0 pin is connected to ground
int main() {
    while (1) {
        lcd.printf("Hello.I'm MBED. ");
        lcd.printf("Microcontroller ");
        wait(3);

        lcd.printf("Rapid Protoyping");
        lcd.printf("System created  ");
        wait(3);

        lcd.printf("by ARM-Cambridge");
        lcd.printf("That's  ENGLAND!");
        wait(3);

        lcd.printf("You can write   ");
        lcd.printf("a program for me");
        wait(3);

        lcd.printf("quickly & easily");
        lcd.printf("using the online");
        wait(3);

        lcd.printf("C compiler in   ");
        lcd.printf("the cloud. There");
        wait(3);

        lcd.printf("is also a vast  ");
        lcd.printf("cookbook online ");
        wait(3);

        lcd.printf("where you can   ");
        lcd.printf("find lots of    ");
        wait(3);

        lcd.printf("example code to ");
        lcd.printf("experiment with ");
        wait(3);

        lcd.printf("to create       ");
        lcd.printf("programs like   ");
        wait(3);

        lcd.printf("this one in     ");
        lcd.printf("minutes!        ");
        wait(3);

        lcd.printf("                ");
        lcd.printf("                ");
        wait(3);

        lcd.printf("Temp is:        ");
        lcd.printf("%.1f degrees C\n", temperature.read()) ;
        wait(3);

    }
}