Simon Stillwell / Mbed 2 deprecated LED1OnIfP5On

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 my first go at reading DigitalIn.
00005 // If pin 5 is on, I light LED1.
00006 // Thus, running a wire from pin2 (+5v) to pin5 LED 1 comes on.
00007 // Also, running the Light Dependent Resistor (LDR) that came with my SKPANG kit
00008 // from pin2 to pin5 LED1 comes on if there is light
00009 // and goes off when the LDR is covered.
00010 //
00011 
00012 
00013 DigitalOut myled1(LED1);
00014 DigitalIn myIn5(p5);
00015 
00016 int main() 
00017 {
00018     while(1) 
00019     {
00020         if (myIn5)
00021         {
00022             myled1 = 1;
00023         }
00024         else
00025         {
00026             myled1 = 0;
00027         }
00028     }
00029 }