ST / Mbed 2 deprecated DISCO-F334C8_HiBrightLED_demo

Dependencies:   HiBrightLED mbed

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers main.cpp Source File

main.cpp

00001 #include "mbed.h"
00002 #include "HiBrightLED.h"
00003 
00004 /*
00005  Example showing how to use the High Brightness LED present
00006    on the DISCO-F334C8 board.
00007 */
00008 
00009 DigitalOut red_led(LED1);
00010 
00011 InterruptIn user_button(USER_BUTTON);
00012 
00013 HiBrightLED hib_led;
00014 
00015 uint32_t blink;
00016   
00017 void button_pressed() {
00018   static uint32_t state = 1;
00019   blink = 0;
00020   switch (state) {
00021     case 0:
00022       hib_led = 0.0; // OFF
00023       break;
00024     case 1:
00025       hib_led = 0.05; // ON intermediate 1
00026       break;
00027     case 2:
00028       hib_led = 0.2; // ON intermediate 2
00029       break;
00030     case 3:
00031       hib_led = 1.0; // ON MAX
00032       break;
00033     case 4:
00034       hib_led = 0.0; // ON / OFF
00035       blink = 1;
00036     default:
00037       break;
00038   }
00039   state++;
00040   if (state > 4) state = 0;
00041 }
00042 
00043 int main()
00044 {
00045   user_button.fall(&button_pressed);
00046   
00047   while(1)
00048   {
00049      red_led = !red_led;
00050      if (blink) {
00051        hib_led = !hib_led;
00052      }
00053      wait(0.3);
00054   }
00055 }