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.
Dependencies: mbed
Fork of FernsehSimulator by
main.cpp@4:f6840272e341, 2016-04-08 (annotated)
- Committer:
- marcel1691
- Date:
- Fri Apr 08 12:17:43 2016 +0000
- Revision:
- 4:f6840272e341
- Parent:
- 3:e612c5f0c23d
Fernsehsimulator mit LED auf Shield
Who changed what in which revision?
| User | Revision | Line number | New contents of line |
|---|---|---|---|
| marcel1691 | 2:0362ad565944 | 1 | /** Zahlfallszahlen erzeugen und damit Fernsehsimulator fuettern |
| marcel1691 | 0:96b9c5faa0d1 | 2 | */ |
| marcel1691 | 0:96b9c5faa0d1 | 3 | #include "mbed.h" |
| marcel1691 | 2:0362ad565944 | 4 | #include <time.h> |
| marcel1691 | 0:96b9c5faa0d1 | 5 | |
| marcel1691 | 4:f6840272e341 | 6 | DigitalOut led[] = { DigitalOut( D10 ), DigitalOut( D11 ), DigitalOut( D12 ), DigitalOut( D13 ) }; |
| marcel1691 | 2:0362ad565944 | 7 | AnalogIn poti( A0 ); |
| marcel1691 | 0:96b9c5faa0d1 | 8 | |
| marcel1691 | 0:96b9c5faa0d1 | 9 | int main() |
| marcel1691 | 0:96b9c5faa0d1 | 10 | { |
| marcel1691 | 4:f6840272e341 | 11 | printf( "Fernsehsimulator\n" ); |
| marcel1691 | 0:96b9c5faa0d1 | 12 | |
| marcel1691 | 2:0362ad565944 | 13 | time_t t; |
| marcel1691 | 2:0362ad565944 | 14 | time(&t); |
| marcel1691 | 2:0362ad565944 | 15 | srand( (unsigned int)t ); /* Zufallsgenerator initialisieren */ |
| marcel1691 | 0:96b9c5faa0d1 | 16 | |
| marcel1691 | 2:0362ad565944 | 17 | while ( 1 ) |
| marcel1691 | 2:0362ad565944 | 18 | { |
| marcel1691 | 4:f6840272e341 | 19 | for ( int i = 0; i < 4; i++ ) |
| marcel1691 | 4:f6840272e341 | 20 | { |
| marcel1691 | 4:f6840272e341 | 21 | int r = rand(); |
| marcel1691 | 4:f6840272e341 | 22 | led[i] = ( (r % (i+2) ) != 0 ) ? 1 : 0; |
| marcel1691 | 4:f6840272e341 | 23 | } |
| marcel1691 | 2:0362ad565944 | 24 | |
| marcel1691 | 2:0362ad565944 | 25 | wait( poti.read() ); |
| marcel1691 | 0:96b9c5faa0d1 | 26 | } |
| marcel1691 | 0:96b9c5faa0d1 | 27 | } |
