takahiro ishikawa / Mbed 2 deprecated ledtest

Dependencies:   mbed

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers test.cpp Source File

test.cpp

00001 #include "mbed.h"
00002 
00003 BusOut leds(P1_13, P1_14, P1_22, P0_17, P0_18, P0_19, P1_15, P0_1);
00004 
00005 void single(unsigned char bit);
00006 void all();
00007 void rotate();
00008 void takahiro();
00009 void takahiro2();
00010 
00011 int main()
00012 {
00013 
00014     while(1)
00015     {
00016         single(0);
00017         wait(2);
00018         all();
00019         all();
00020         rotate();
00021         rotate();
00022         takahiro();
00023         takahiro2();    
00024     }
00025 }
00026 
00027 void single(unsigned char bit)
00028 {
00029     leds = 1 << bit;
00030 }
00031 
00032 void all()
00033 {
00034     leds = 0xff;
00035     wait(0.2);
00036     leds = 0x00;
00037     wait(0.2);
00038 }
00039 
00040 
00041 void rotate()
00042 {
00043     int bitt;
00044     for(bitt = 0x00; bitt < 10; bitt++)
00045     {
00046         leds = 1 << bitt;
00047         wait(0.2);
00048     }
00049 }
00050 void takahiro()
00051 {
00052     int bitt;
00053     for(bitt = 0x00; bitt < 10; bitt++)
00054     {
00055         leds = 0x80 >> bitt;
00056         wait(0.2);
00057     }
00058 }
00059 
00060 void takahiro2()
00061 {
00062    leds = 0x18;
00063    wait(0.5);
00064    leds = 0x24;
00065    wait(0.5);
00066    leds = 0x42;
00067    wait(0.5);
00068    leds = 0x81;
00069    wait(0.5);
00070 }