20x4 LCD with SRM32F407

Dependencies:   mbed TextLCD

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 
00006 TextLCD lcd(PC_15, PC_13, PC_14, PE_6, PE_4, PE_2,TextLCD::LCD20x4); // rs, e, d4-d7
00007 AnalogIn   adcPB0(PB_0);
00008 AnalogIn adcPB1(PB_1);
00009 AnalogOut dacPA5(PA_5); 
00010 DigitalIn buttonPA0 (PA_0);
00011 DigitalIn extbutton1PE5 (PE_5);
00012 DigitalIn extbutton2PE3 (PE_3);
00013 DigitalOut rLED(PD_14);   // on board red LED, DO
00014 DigitalOut bLED(PD_15);   // on board blue LED. DO
00015 DigitalOut gLED(PD_12);   // on board green LED, DO
00016 DigitalOut oLED(PD_13);   // on board orange LED, DO
00017 
00018 DigitalOut exRef(PE_7);   // on board orange LED, DO
00019 
00020 
00021 
00022 uint32_t adcval=0;
00023 uint16_t val=0;
00024 
00025 
00026 int main() {
00027     dacPA5=0.0f;
00028     extbutton1PE5.mode(PullUp);
00029     extbutton2PE3.mode(PullUp);
00030     exRef=1;
00031     
00032     while(1)
00033     {
00034         lcd.cls();
00035     lcd.printf("mbed with STM32F407G");
00036     lcd.printf(" !! It Worked !!\n");
00037     if(dacPA5<1.00f)
00038     dacPA5 = dacPA5+0.002442f;
00039     adcval=0;
00040     for(int i=0;i<4096;i++)
00041     {
00042     adcval= adcval + 4095*adcPB1.read_u16()/65535; // 12 bit value
00043     }
00044     val=adcval/4096;
00045     lcd.printf("  ADC on PB1: %d\n", val);
00046     lcd.printf("AREF Volts: %f",(2.9464*val/4095));
00047    wait(.25);
00048    rLED =extbutton1PE5.read();
00049    bLED =extbutton2PE3.read();
00050    gLED =!extbutton1PE5.read();
00051    oLED =!extbutton2PE3.read();
00052    while(buttonPA0)
00053    {}
00054    
00055     }
00056 }