Simon Stillwell / Mbed 2 deprecated ExternalLEDBinaryDisplay

Dependencies:   mbed

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers main.cpp Source File

main.cpp

00001 #include "mbed.h"
00002 
00003 //
00004 //This is based on my BinaryLEDDisplay
00005 //It is my first go at using DigitalOut on pins rather than Mbed's own LEDs
00006 //The 4 External LEDS count in binary from 0 to 15
00007 //Each LED is connected to it's own pin and to pin1 (ground)
00008 //
00009 DigitalOut myled1(p5);
00010 DigitalOut myled2(p6);
00011 DigitalOut myled3(p7);
00012 DigitalOut myled4(p8);
00013 Timer mytimer;
00014 
00015 int main() 
00016 {
00017     myled1 = 1;
00018     myled2 = 1;
00019     myled3 = 1;
00020     myled4 = 1;
00021     mytimer.start();
00022     
00023     int intStart = mytimer.read_ms();
00024     int intCounter = 0;    
00025     bool blnSetalloff = true;
00026     while(1) 
00027     {
00028         if((mytimer.read_ms() - intStart) >= 250)
00029         {
00030             if (blnSetalloff)
00031             {
00032                 myled1 = 0;
00033                 myled2 = 0;
00034                 myled3 = 0;
00035                 myled4 = 0;
00036                 blnSetalloff = false;
00037                 continue;
00038             }
00039 
00040             if (intCounter % 16 > 7)
00041             {
00042                 myled1 = 1;
00043             }
00044             if (intCounter % 8 > 3)
00045             {
00046                 myled2 = 1;
00047             }
00048             if (intCounter % 4 > 1)
00049             {
00050                 myled3 = 1;
00051             }
00052             if (intCounter % 2 == 1)
00053             {
00054                 myled4 = 1;
00055             }
00056             intCounter +=1;
00057             blnSetalloff = true;
00058             intStart = mytimer.read_ms();
00059         }
00060     }
00061 }