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
Revision 4:f6840272e341, committed 2016-04-08
- Comitter:
- marcel1691
- Date:
- Fri Apr 08 12:17:43 2016 +0000
- Parent:
- 3:e612c5f0c23d
- Commit message:
- Fernsehsimulator mit LED auf Shield
Changed in this revision
main.cpp | Show annotated file Show diff for this revision Revisions of this file |
--- a/main.cpp Thu Mar 31 13:04:58 2016 +0000 +++ b/main.cpp Fri Apr 08 12:17:43 2016 +0000 @@ -3,45 +3,25 @@ #include "mbed.h" #include <time.h> -SPI spi(D11, NC, D13); // mosi, miso, sclk +DigitalOut led[] = { DigitalOut( D10 ), DigitalOut( D11 ), DigitalOut( D12 ), DigitalOut( D13 ) }; AnalogIn poti( A0 ); -/** 3 x 3 Werte */ -unsigned int strip[9]; - -void writeLED() -{ - for ( int p = 0; p < 9; p++ ) - spi.write( strip[p] ); -} - -void clearLED() -{ - for ( int p = 0; p < 9; p++ ) - { - strip[p] = 0; - spi.write( strip[p] ); - } -} - int main() { - printf( "LED Strip Test \n" ); + printf( "Fernsehsimulator\n" ); - spi.format( 8,0 ); - spi.frequency( 800000 ); - - clearLED(); time_t t; time(&t); srand( (unsigned int)t ); /* Zufallsgenerator initialisieren */ while ( 1 ) { - for ( int i = 0; i < 9; i++ ) - strip[i] = rand() % 64 + 1; + for ( int i = 0; i < 4; i++ ) + { + int r = rand(); + led[i] = ( (r % (i+2) ) != 0 ) ? 1 : 0; + } - writeLED(); wait( poti.read() ); } } \ No newline at end of file