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@0:0571a4f49d00, 2014-11-12 (annotated)
- Committer:
- kklokeshkumar
- Date:
- Wed Nov 12 10:21:13 2014 +0000
- Revision:
- 0:0571a4f49d00
ADC DAC and serial com rev1
Who changed what in which revision?
| User | Revision | Line number | New contents of line |
|---|---|---|---|
| kklokeshkumar | 0:0571a4f49d00 | 1 | #include "mbed.h" |
| kklokeshkumar | 0:0571a4f49d00 | 2 | |
| kklokeshkumar | 0:0571a4f49d00 | 3 | Serial pc(USBTX, USBRX); |
| kklokeshkumar | 0:0571a4f49d00 | 4 | AnalogOut signal(PTE30); |
| kklokeshkumar | 0:0571a4f49d00 | 5 | DigitalOut myled(LED2); |
| kklokeshkumar | 0:0571a4f49d00 | 6 | DigitalIn sw1(PTB0); |
| kklokeshkumar | 0:0571a4f49d00 | 7 | DigitalIn sw2(PTB1); |
| kklokeshkumar | 0:0571a4f49d00 | 8 | |
| kklokeshkumar | 0:0571a4f49d00 | 9 | int main() |
| kklokeshkumar | 0:0571a4f49d00 | 10 | { |
| kklokeshkumar | 0:0571a4f49d00 | 11 | char ot =0; |
| kklokeshkumar | 0:0571a4f49d00 | 12 | signal = 0; |
| kklokeshkumar | 0:0571a4f49d00 | 13 | char inp; |
| kklokeshkumar | 0:0571a4f49d00 | 14 | float seconds; |
| kklokeshkumar | 0:0571a4f49d00 | 15 | pc.printf("Enter the seconds\n"); |
| kklokeshkumar | 0:0571a4f49d00 | 16 | pc.putc(inp = pc.getc()); |
| kklokeshkumar | 0:0571a4f49d00 | 17 | //pc.printf("\n seconds entered was %c \n",inp); |
| kklokeshkumar | 0:0571a4f49d00 | 18 | seconds = (float) (inp-48); |
| kklokeshkumar | 0:0571a4f49d00 | 19 | pc.printf("\n seconds entered was %f \n",seconds); |
| kklokeshkumar | 0:0571a4f49d00 | 20 | myled = 1; |
| kklokeshkumar | 0:0571a4f49d00 | 21 | while(1) { |
| kklokeshkumar | 0:0571a4f49d00 | 22 | |
| kklokeshkumar | 0:0571a4f49d00 | 23 | if (!sw1 && sw2) |
| kklokeshkumar | 0:0571a4f49d00 | 24 | { |
| kklokeshkumar | 0:0571a4f49d00 | 25 | myled = 0; |
| kklokeshkumar | 0:0571a4f49d00 | 26 | wait(seconds); |
| kklokeshkumar | 0:0571a4f49d00 | 27 | signal = 0.122; |
| kklokeshkumar | 0:0571a4f49d00 | 28 | myled = 1; |
| kklokeshkumar | 0:0571a4f49d00 | 29 | } |
| kklokeshkumar | 0:0571a4f49d00 | 30 | if (!sw2) |
| kklokeshkumar | 0:0571a4f49d00 | 31 | { |
| kklokeshkumar | 0:0571a4f49d00 | 32 | //myled = 1; |
| kklokeshkumar | 0:0571a4f49d00 | 33 | signal = 0; |
| kklokeshkumar | 0:0571a4f49d00 | 34 | // myled = 0; |
| kklokeshkumar | 0:0571a4f49d00 | 35 | } |
| kklokeshkumar | 0:0571a4f49d00 | 36 | /*for(int i=3000; i<10000; i++) |
| kklokeshkumar | 0:0571a4f49d00 | 37 | { |
| kklokeshkumar | 0:0571a4f49d00 | 38 | signal.write_u16(i); |
| kklokeshkumar | 0:0571a4f49d00 | 39 | pc.printf(" %d ",i); |
| kklokeshkumar | 0:0571a4f49d00 | 40 | ot = ~ot; |
| kklokeshkumar | 0:0571a4f49d00 | 41 | myled = ot; |
| kklokeshkumar | 0:0571a4f49d00 | 42 | wait(0.01); |
| kklokeshkumar | 0:0571a4f49d00 | 43 | }*/ |
| kklokeshkumar | 0:0571a4f49d00 | 44 | } |
| kklokeshkumar | 0:0571a4f49d00 | 45 | //signal = 1; |
| kklokeshkumar | 0:0571a4f49d00 | 46 | } |