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:f7c1b30aa1cd, 2009-11-02 (annotated)
- Committer:
- Bobty
- Date:
- Mon Nov 02 13:10:45 2009 +0000
- Revision:
- 0:f7c1b30aa1cd
Who changed what in which revision?
| User | Revision | Line number | New contents of line |
|---|---|---|---|
| Bobty | 0:f7c1b30aa1cd | 1 | // AnalogIn reading 16-bit samples |
| Bobty | 0:f7c1b30aa1cd | 2 | |
| Bobty | 0:f7c1b30aa1cd | 3 | #include "mbed.h" |
| Bobty | 0:f7c1b30aa1cd | 4 | |
| Bobty | 0:f7c1b30aa1cd | 5 | AnalogIn input(p20); |
| Bobty | 0:f7c1b30aa1cd | 6 | DigitalOut led1(LED1); |
| Bobty | 0:f7c1b30aa1cd | 7 | |
| Bobty | 0:f7c1b30aa1cd | 8 | int main() { |
| Bobty | 0:f7c1b30aa1cd | 9 | unsigned short samples[1024]; |
| Bobty | 0:f7c1b30aa1cd | 10 | |
| Bobty | 0:f7c1b30aa1cd | 11 | for(int i=0; i<1024; i++) { |
| Bobty | 0:f7c1b30aa1cd | 12 | samples[i] = input.read_u16(); |
| Bobty | 0:f7c1b30aa1cd | 13 | wait_ms(1); |
| Bobty | 0:f7c1b30aa1cd | 14 | } |
| Bobty | 0:f7c1b30aa1cd | 15 | |
| Bobty | 0:f7c1b30aa1cd | 16 | printf("Results:\n"); |
| Bobty | 0:f7c1b30aa1cd | 17 | for(int i=0; i<1024; i++) { |
| Bobty | 0:f7c1b30aa1cd | 18 | if (samples[i] > 0x100) |
| Bobty | 0:f7c1b30aa1cd | 19 | printf("%d, 0x%04X\n", i, samples[i]); |
| Bobty | 0:f7c1b30aa1cd | 20 | } |
| Bobty | 0:f7c1b30aa1cd | 21 | } |