Glowing_Gem_02 (usage of loops and hex output to activate the leds)

Dependencies:   mbed

Glowing_Gem_02.cpp

Committer:
kirk
Date:
2011-02-10
Revision:
2:699459ba4d70
Parent:
1:d12dad8f1788

File content as of revision 2:699459ba4d70:

/***************************************************************
* date:    10/02/2011
* title:   Glowing Gem V2.0 w FOR-Loops
* Desc.:   Activate and deactivate the blue Leds in an easy way.
*
* Author:  kirk
* Website: http://mbed.com/kirk
****************************************************************/

#include "mbed.h"
#include <math.h>

//LED init
BusOut Bits(LED1,LED2,LED3,LED4); //LED Output Glowing_Gem_02

// def, init
char HexWert = 0x00;
int i,j;

int main() {

    // Endlosschleife ... soll ja nicht sofort aufhören zu blinken ... 
    while(1) {
    
        //schreibe Hex-Werte in Variable HexWert und gib die Werte mehrmals aus
         for (i=0;i<5;i++) {
            HexWert = 0xA;
            Bits = HexWert;
            wait(0.1);
            HexWert = 0x5;
            Bits = HexWert;
            wait(0.1);
        }


        HexWert = 0x0;
        Bits = HexWert;
        wait(0.1);

        for (i=0;i<5;i++) {
            HexWert = 0x9;
            Bits = HexWert;
            wait(0.1);
            HexWert = 0x6;
            Bits = HexWert;
            wait(0.1);
        }
        int k=1;
        
        for (i=0;i<2;i++) {
        
            k*=-1;
            
            HexWert = 0x0;
            Bits = HexWert;
            wait(0.2);
            
            HexWert = 0xF;
            Bits = HexWert;
            wait(0.2);
            
            HexWert = 0x0;
            Bits = HexWert;
            wait(0.2);  

            for(j=0;j<3;j++) {
                if(k==1) {
                    HexWert = 0x1;
                    Bits = HexWert;
                    wait(0.2);
                    HexWert = 0x3;
                    Bits = HexWert;
                    wait(0.2);
                    HexWert = 0x7;
                    Bits = HexWert;
                    wait(0.2);
                    HexWert = 0xF;
                    Bits = HexWert;
                    wait(0.2);
                }
                else {
                    HexWert = 0x8;
                    Bits = HexWert;
                    wait(0.2);
                    HexWert = 0x4;
                    Bits = HexWert;
                    wait(0.2);
                    HexWert = 0x2;
                    Bits = HexWert;
                    wait(0.2);
                    HexWert = 0x1;
                    Bits = HexWert;
                    wait(0.2);
                }
            }
        }
     
    }
}