Because the light of four LED flows, the button is stopped pushing and seen at the decided position. Do you make it to good?

Dependencies:   mbed

main.cpp

Committer:
airwhite
Date:
2010-10-15
Revision:
0:1d5cfa0bead6

File content as of revision 0:1d5cfa0bead6:

/*
    Name:       Roulette
    Function:   IntteruptIn, BusOut
    Parts:      Push Button
*/

#include "mbed.h"

InterruptIn button(p5);                 // Push Button
BusOut myleds(LED1, LED2, LED3, LED4); 
int save;

void blink() {
    save = myleds;
    myleds = 0;    wait(0.3);
    myleds = save; wait(0.3);
    myleds = 0;    wait(0.3);
    myleds = save; wait(0.3);
    myleds = 0;    wait(0.3);
    myleds = save; wait(0.3);
    myleds = 0;    wait(3);
}

int main() {
    button.rise(&blink);
    while(true) {
        myleds = 1; wait(0.1);
        myleds = 2; wait(0.1);
        myleds = 4; wait(0.1);
        myleds = 8; wait(0.1);
    }
}