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 00002 00003 #include "mbed.h" 00004 00005 Serial uart1(PA_13, PA_14); // tx, rx 00006 Serial uart2(PC_10, PC_11); // tx, rx 00007 DigitalOut myD1(D10); 00008 DigitalOut myD2(D11); 00009 DigitalOut myD3(D12); 00010 DigitalOut myD4(D2); 00011 AnalogIn myA1(A1); 00012 AnalogIn myA2(A2); 00013 AnalogIn myA3(A3); 00014 PwmOut PWM1(D3); 00015 PwmOut PWM2(D5); 00016 PwmOut PWM3(D6); 00017 00018 Timeout timeout; 00019 00020 void attimeout() 00021 { 00022 myD1 = 0; 00023 myD2 = 0; 00024 myD3 = 0; 00025 myD4 = 0; 00026 } 00027 00028 int main() { 00029 uart1.baud(115200); 00030 uart2.baud(115200); 00031 PWM1.period_us(500); 00032 PWM2.period_us(500); 00033 PWM3.period_us(500); 00034 PWM1 = 0.2; 00035 PWM2 = 0.5; 00036 PWM3 = 0.8; 00037 uart2.printf("uart2:for Loopback test,please input something\n"); 00038 uart1.printf("start testing uart1 digitalOut and PWM and analogIn\n"); 00039 while(1){ 00040 while(uart2.readable()){ 00041 uart2.printf("%c", uart2.getc()); 00042 } 00043 00044 timeout.attach(&attimeout,2); 00045 00046 myD1 = 1; 00047 myD2 = 1; 00048 myD3 = 1; 00049 myD4 = 1; 00050 wait(0.25); 00051 00052 uart1.printf("A1:%02f\n",myA1.read()*3.3); 00053 uart1.printf("A2:%02f\n",myA2.read()*3.3); 00054 uart1.printf("A3:%02f\n",myA3.read()*3.3); 00055 } 00056 } 00057 00058 00059 00060
Generated on Fri Jul 22 2022 04:35:08 by
1.7.2