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
Diff: main.cpp
- Revision:
- 2:0362ad565944
- Parent:
- 1:4e24bd21f2ce
- Child:
- 3:e612c5f0c23d
--- a/main.cpp Sun May 24 07:27:19 2015 +0000
+++ b/main.cpp Fri Mar 25 18:51:10 2016 +0000
@@ -1,8 +1,10 @@
-/** 9.6 Schreibt die Lauflicht Übung aus dem 1. Kurs auf die LED Strips um.
+/** Zahlfallszahlen erzeugen und damit Fernsehsimulator fuettern
*/
#include "mbed.h"
+#include <time.h>
SPI spi(D11, NC, D13); // mosi, miso, sclk
+AnalogIn poti( A0 );
/** 3 x 3 Werte */
unsigned int strip[9];
@@ -28,55 +30,18 @@
spi.format( 8,0 );
spi.frequency( 800000 );
-
- while (true)
- {
- // Gruen, Rot, Blau - von Dunkel bis Hell
- for ( int i = 0; i < 128; i+=32 )
- {
- // LED 1
- strip[0] = i;
- strip[1] = 0;
- strip[2] = 0;
- // LED 2
- strip[3] = 0;
- strip[4] = i;
- strip[5] = 0;
- // LED 3
- strip[6] = 0;
- strip[7] = 0;
- strip[8] = i;
- writeLED();
- wait( 0.1 );
- }
- wait( 1.0 );
- clearLED();
+
+ clearLED();
+ time_t t;
+ time(&t);
+ srand( (unsigned int)t ); /* Zufallsgenerator initialisieren */
- // Lauflicht (5 x 4 Zustaende)
- int p = 0;
- for ( int i = 0; i < 20; i++ )
- {
- p++;
- switch ( p )
- {
- case 1:
- strip[0] = strip[1] = strip[2] = 32;
- break;
- case 2:
- strip[0] = strip[1] = strip[2] = 0;
- strip[3] = strip[4] = strip[5] = 32;
- break;
- case 3:
- strip[3] = strip[4] = strip[5] = 0;
- strip[6] = strip[7] = strip[8] = 32;
- break;
- default:
- clearLED();
- p = 0;
- break;
- }
- writeLED();
- wait( 0.2 );
- }
+ while ( 1 )
+ {
+ for ( int i = 0; i < 9; i++ )
+ strip[i] = rand() % 64 + 1;
+
+ writeLED();
+ wait( poti.read() );
}
}
\ No newline at end of file
