3 fuc:fat sd eth
Dependencies: FATFileSystem SDFileSystem WIZnetInterface mbed
Fork of adc_dac by
main.cpp@1:2cd31d24d6fc, 2016-07-15 (annotated)
- Committer:
- jh_ndm
- Date:
- Fri Jul 15 01:20:01 2016 +0000
- Revision:
- 1:2cd31d24d6fc
- Parent:
- 0:695e35fce077
- Child:
- 2:b67216fc6104
dfrobot basis
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
jh_ndm | 0:695e35fce077 | 1 | /* |
jh_ndm | 0:695e35fce077 | 2 | #include "mbed.h" |
jh_ndm | 0:695e35fce077 | 3 | AnalogIn battery(A3); |
jh_ndm | 1:2cd31d24d6fc | 4 | Serial uart1(PA_13,PA_14); |
jh_ndm | 0:695e35fce077 | 5 | int main(){ |
jh_ndm | 0:695e35fce077 | 6 | while(1){ |
jh_ndm | 0:695e35fce077 | 7 | if(battery > 0.5){ |
jh_ndm | 1:2cd31d24d6fc | 8 | uart1.printf("%02f\n",battery.read()*3.3); |
jh_ndm | 0:695e35fce077 | 9 | wait(1); |
jh_ndm | 0:695e35fce077 | 10 | } |
jh_ndm | 0:695e35fce077 | 11 | } |
jh_ndm | 0:695e35fce077 | 12 | } |
jh_ndm | 0:695e35fce077 | 13 | */ |
jh_ndm | 0:695e35fce077 | 14 | |
jh_ndm | 0:695e35fce077 | 15 | /********uart0 demo******** |
jh_ndm | 0:695e35fce077 | 16 | #include "mbed.h" |
jh_ndm | 0:695e35fce077 | 17 | |
jh_ndm | 1:2cd31d24d6fc | 18 | Serial uart1(PA_13, PA_14); // tx, rx |
jh_ndm | 0:695e35fce077 | 19 | |
jh_ndm | 0:695e35fce077 | 20 | int main() { |
jh_ndm | 0:695e35fce077 | 21 | pc.printf("Please input something\n"); |
jh_ndm | 0:695e35fce077 | 22 | |
jh_ndm | 0:695e35fce077 | 23 | while(1) { |
jh_ndm | 1:2cd31d24d6fc | 24 | char c = uart1.getc(); |
jh_ndm | 1:2cd31d24d6fc | 25 | uart1.printf("%s\n",c); |
jh_ndm | 0:695e35fce077 | 26 | } |
jh_ndm | 0:695e35fce077 | 27 | } |
jh_ndm | 0:695e35fce077 | 28 | */ |
jh_ndm | 0:695e35fce077 | 29 | |
jh_ndm | 0:695e35fce077 | 30 | /********uart2 demo******** |
jh_ndm | 0:695e35fce077 | 31 | #include "mbed.h" |
jh_ndm | 0:695e35fce077 | 32 | |
jh_ndm | 1:2cd31d24d6fc | 33 | Serial uart2(PC_10, PC_11); // tx, rx |
jh_ndm | 0:695e35fce077 | 34 | |
jh_ndm | 0:695e35fce077 | 35 | int main() { |
jh_ndm | 1:2cd31d24d6fc | 36 | uart2.printf("Please input something\n"); |
jh_ndm | 0:695e35fce077 | 37 | |
jh_ndm | 0:695e35fce077 | 38 | while(1) { |
jh_ndm | 1:2cd31d24d6fc | 39 | char c = uart2.getc(); |
jh_ndm | 1:2cd31d24d6fc | 40 | uart2.printf("%s\n",c); |
jh_ndm | 0:695e35fce077 | 41 | } |
jh_ndm | 0:695e35fce077 | 42 | } |
jh_ndm | 0:695e35fce077 | 43 | */ |
jh_ndm | 0:695e35fce077 | 44 | |
jh_ndm | 0:695e35fce077 | 45 | /**********Digital demo********** |
jh_ndm | 0:695e35fce077 | 46 | #include "mbed.h" |
jh_ndm | 0:695e35fce077 | 47 | |
jh_ndm | 0:695e35fce077 | 48 | DigitalOut num1(D10); |
jh_ndm | 0:695e35fce077 | 49 | DigitalOut num2(D11); |
jh_ndm | 0:695e35fce077 | 50 | DigitalOut num3(D12); |
jh_ndm | 0:695e35fce077 | 51 | DigitalOut num4(D2); |
jh_ndm | 0:695e35fce077 | 52 | DigitalOut num5(D3); |
jh_ndm | 0:695e35fce077 | 53 | |
jh_ndm | 0:695e35fce077 | 54 | int main(){ |
jh_ndm | 0:695e35fce077 | 55 | while(1){ |
jh_ndm | 0:695e35fce077 | 56 | wait(0.25); |
jh_ndm | 0:695e35fce077 | 57 | num1 = 1; |
jh_ndm | 0:695e35fce077 | 58 | num2 = 1; |
jh_ndm | 0:695e35fce077 | 59 | num3 = 1; |
jh_ndm | 0:695e35fce077 | 60 | num4 = 1; |
jh_ndm | 0:695e35fce077 | 61 | num5 = 1; |
jh_ndm | 0:695e35fce077 | 62 | wait(0.25); |
jh_ndm | 0:695e35fce077 | 63 | num1 = 0; |
jh_ndm | 0:695e35fce077 | 64 | num2 = 0; |
jh_ndm | 0:695e35fce077 | 65 | num3 = 0; |
jh_ndm | 0:695e35fce077 | 66 | num4 = 0; |
jh_ndm | 0:695e35fce077 | 67 | num5 = 0; |
jh_ndm | 0:695e35fce077 | 68 | } |
jh_ndm | 0:695e35fce077 | 69 | } |
jh_ndm | 0:695e35fce077 | 70 | */ |
jh_ndm | 0:695e35fce077 | 71 | |
jh_ndm | 0:695e35fce077 | 72 | /**********analog demo*********** |
jh_ndm | 0:695e35fce077 | 73 | #include "mbed.h" |
jh_ndm | 0:695e35fce077 | 74 | AnalogIn battery5(A0); |
jh_ndm | 0:695e35fce077 | 75 | AnalogIn battery4(PC_9); |
jh_ndm | 0:695e35fce077 | 76 | AnalogIn battery3(D5); |
jh_ndm | 1:2cd31d24d6fc | 77 | Serial uart1(PA_13,PA_14); |
jh_ndm | 1:2cd31d24d6fc | 78 | //Serial pc(USBTX,USBRX); |
jh_ndm | 0:695e35fce077 | 79 | int main(){ |
jh_ndm | 0:695e35fce077 | 80 | while(1){ |
jh_ndm | 0:695e35fce077 | 81 | //if(battery3 > 0.5){ |
jh_ndm | 1:2cd31d24d6fc | 82 | // uart1.printf("%f\n",battery3.read()*3.3); |
jh_ndm | 0:695e35fce077 | 83 | // wait(0.2); |
jh_ndm | 0:695e35fce077 | 84 | // } |
jh_ndm | 0:695e35fce077 | 85 | //if(battery4 > 0.5){ |
jh_ndm | 1:2cd31d24d6fc | 86 | // uart1.printf("%f\n",battery4.read()); |
jh_ndm | 0:695e35fce077 | 87 | //wait(0.2); |
jh_ndm | 0:695e35fce077 | 88 | //} |
jh_ndm | 0:695e35fce077 | 89 | if(battery5 > 0.5){ |
jh_ndm | 1:2cd31d24d6fc | 90 | uart1.printf("%f\n",battery5.read()); |
jh_ndm | 0:695e35fce077 | 91 | wait(0.2); |
jh_ndm | 0:695e35fce077 | 92 | } |
jh_ndm | 0:695e35fce077 | 93 | } |
jh_ndm | 0:695e35fce077 | 94 | } |
jh_ndm | 0:695e35fce077 | 95 | */ |
jh_ndm | 0:695e35fce077 | 96 | |
jh_ndm | 0:695e35fce077 | 97 | |
jh_ndm | 0:695e35fce077 | 98 | #include"mbed.h" |
jh_ndm | 0:695e35fce077 | 99 | AnalogIn battery(A2); |
jh_ndm | 1:2cd31d24d6fc | 100 | Serial uart1(PA_13,PA_14); |
jh_ndm | 0:695e35fce077 | 101 | int main(){ |
jh_ndm | 0:695e35fce077 | 102 | while(1){ |
jh_ndm | 0:695e35fce077 | 103 | if(battery > 0.5){ |
jh_ndm | 1:2cd31d24d6fc | 104 | uart1.printf("%f",battery.read()); |
jh_ndm | 0:695e35fce077 | 105 | wait(1); |
jh_ndm | 0:695e35fce077 | 106 | } |
jh_ndm | 0:695e35fce077 | 107 | } |
jh_ndm | 0:695e35fce077 | 108 | } |