Embedded system Fun Blog
























































Find out all the best information, libraries and circuit about the latest Embedded systems.
Showing posts with label del. Show all posts
Showing posts with label del. Show all posts

Saturday, 7 January 2012

MBED Example: How to use DigitalOut to Toggle a LED

.from: http://mbed.org/projects/libraries/svn/mbed/trunk/DigitalOut.h

// Toggle a LED
#include "mbed.h"

DigitalOut led(LED1);

int main() {
        while(1) {
        led = !led;
        wait(0.2);
    }
}

MBED Example: Flash an LED while a DigitalIn is true

.from: http://mbed.org/projects/libraries/svn/mbed/trunk/DigitalIn.h

/* mbed Microcontroller Library - DigitalIn
 * Copyright (c) 2006-2011 ARM Limited. All rights reserved.
 */ 

// Flash an LED while a DigitalIn is true
#include "mbed.h"
DigitalIn enable(p5);
DigitalOut led(LED1);
int main() {
  while(1) {
  if(enable) {
   led = !led;
  }
   wait(0.25);
  }
}