Nando Daenen / Mbed 2 deprecated DimmingLeds

Dependencies:   mbed

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers main.cpp Source File

main.cpp

00001 /*
00002  *  mbed demo code
00003  *
00004  *   This code has been made for a training session. 
00005  *
00006  *  Copyright (c) 2010 NXP Semiconductors Japan
00007  *  Released under the MIT License: http://mbed.org/license/mit
00008  *
00009  *  revision 1.0  18-Feb-2010   1st release
00010  */
00011 
00012 #include "mbed.h"
00013 
00014 PwmOut led[] = { LED4, LED3, LED2, LED1 };
00015 
00016 int main() {
00017 
00018     unsigned char rate, rate2, rate3, rate4;
00019 
00020     rate=0;
00021     rate2=0;
00022     rate3=0;
00023     rate4=0;
00024     while ( 1 )
00025     {
00026     
00027        
00028              led[ 0 ]    = rate / 255.0;
00029              led[ 1 ]    = rate2 / 255.0;
00030              led[ 2 ]    = rate3 / 255.0;
00031              led[ 3 ]    = rate4 / 255.0;
00032     
00033     
00034                // wait( 0.01 );
00035                 
00036                 if (rate <255 &&  rate2 ==0 && rate3==0 && rate4==0)
00037                 {
00038                 rate++;
00039                 }
00040                 if (rate == 255)
00041                  rate=0;
00042                  
00043                  
00044                  if (rate == 0 &&  rate2 <255 && rate3==0 && rate4==0)
00045                 {
00046                 rate2++;
00047                 }
00048                 if (rate2 == 255)
00049                  rate2=0;
00050                  
00051                     if (rate == 0 &&  rate2 ==0 && rate3 <255 && rate4==0)
00052                 {
00053                 rate3++;
00054                 }
00055                 if (rate3 == 255)
00056                  rate3=0;
00057                  
00058                 if (rate ==0 &&  rate2 ==0 && rate3==0 && rate4<255)
00059                 {
00060                 rate4++;
00061                 }
00062                 if (rate4 == 255)
00063                  rate4=0;
00064                 
00065         
00066    
00067        wait( 0.01 );
00068     }
00069 }
00070 
00071