jiang hao
/
DFRobotMbedTest
for test
main.cpp
- Committer:
- jh_ndm
- Date:
- 2016-07-15
- Revision:
- 1:2cd31d24d6fc
- Parent:
- 0:695e35fce077
- Child:
- 2:b67216fc6104
File content as of revision 1:2cd31d24d6fc:
/* #include "mbed.h" AnalogIn battery(A3); Serial uart1(PA_13,PA_14); int main(){ while(1){ if(battery > 0.5){ uart1.printf("%02f\n",battery.read()*3.3); wait(1); } } } */ /********uart0 demo******** #include "mbed.h" Serial uart1(PA_13, PA_14); // tx, rx int main() { pc.printf("Please input something\n"); while(1) { char c = uart1.getc(); uart1.printf("%s\n",c); } } */ /********uart2 demo******** #include "mbed.h" Serial uart2(PC_10, PC_11); // tx, rx int main() { uart2.printf("Please input something\n"); while(1) { char c = uart2.getc(); uart2.printf("%s\n",c); } } */ /**********Digital demo********** #include "mbed.h" DigitalOut num1(D10); DigitalOut num2(D11); DigitalOut num3(D12); DigitalOut num4(D2); DigitalOut num5(D3); int main(){ while(1){ wait(0.25); num1 = 1; num2 = 1; num3 = 1; num4 = 1; num5 = 1; wait(0.25); num1 = 0; num2 = 0; num3 = 0; num4 = 0; num5 = 0; } } */ /**********analog demo*********** #include "mbed.h" AnalogIn battery5(A0); AnalogIn battery4(PC_9); AnalogIn battery3(D5); Serial uart1(PA_13,PA_14); //Serial pc(USBTX,USBRX); int main(){ while(1){ //if(battery3 > 0.5){ // uart1.printf("%f\n",battery3.read()*3.3); // wait(0.2); // } //if(battery4 > 0.5){ // uart1.printf("%f\n",battery4.read()); //wait(0.2); //} if(battery5 > 0.5){ uart1.printf("%f\n",battery5.read()); wait(0.2); } } } */ #include"mbed.h" AnalogIn battery(A2); Serial uart1(PA_13,PA_14); int main(){ while(1){ if(battery > 0.5){ uart1.printf("%f",battery.read()); wait(1); } } }