smd.iotkit1.ch / Mbed 2 deprecated FernsehSimulator

Dependencies:   mbed

Fork of 1-09-06-Uebung by smd.iotkit1.ch

main.cpp

Committer:
marcel1691
Date:
2016-03-25
Revision:
2:0362ad565944
Parent:
1:4e24bd21f2ce
Child:
3:e612c5f0c23d

File content as of revision 2:0362ad565944:

/** 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];

void writeLED()
{
    for ( int p = 0; p < 6; p++ )
        spi.write( strip[p] );
}

void clearLED()
{
    for ( int p = 0; p < 6; p++ ) 
    {
        strip[p] = 0;
        spi.write( strip[p] );
    }
}

int main()
{
    printf( "LED Strip Test \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;
            
        writeLED();
        wait( poti.read() );          
    }
}