Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
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 }
Generated on Thu Jul 14 2022 14:39:00 by
1.7.2