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.
Revision 0:14d1482ba244, committed 2021-11-02
- Comitter:
- cspista
- Date:
- Tue Nov 02 06:16:16 2021 +0000
- Commit message:
- Final version
Changed in this revision
main.cpp | Show annotated file Show diff for this revision Revisions of this file |
mbed.bld | Show annotated file Show diff for this revision Revisions of this file |
diff -r 000000000000 -r 14d1482ba244 main.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/main.cpp Tue Nov 02 06:16:16 2021 +0000 @@ -0,0 +1,35 @@ +#include "mbed.h" + +AnalogIn cds(A0); // Analog input at PA0 +DigitalOut led(D10); // Led contolled by D10 + +uint32_t measLight(int nmeas) +{ + uint32_t sum0, sum1, diff; + led = 0; + sum0 = 0; + for (int i = 0; i < nmeas; i++) { + sum0 += cds.read_u16(); + } + led = 1; + sum1 = 0; + for (int i = 0; i < nmeas; i++) { + sum1 += cds.read_u16(); + } + if (sum0 > sum1) { + diff= 0; + } else { + diff = (sum1 - sum0) / nmeas; + } + printf("L1: %5d L0: %5d Diff: %5d\r\n",sum1/nmeas, sum0/nmeas, diff); + return diff; +} + +int main() +{ + printf("\r\n Lab03_light_sensor - with averaging\r\n"); + while(1) { + measLight(1000); + wait(2); + } +} \ No newline at end of file
diff -r 000000000000 -r 14d1482ba244 mbed.bld --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/mbed.bld Tue Nov 02 06:16:16 2021 +0000 @@ -0,0 +1,1 @@ +https://os.mbed.com/users/mbed_official/code/mbed/builds/65be27845400 \ No newline at end of file