Realize the Ledfow

Dependencies:   mbed

Fork of DigitalOut_HelloWorld by mbed official

Committer:
shiyilei
Date:
Tue Oct 14 02:05:10 2014 +0000
Revision:
3:743f42c80067
Parent:
2:b4e2eee99a28
use the GPIO to realize the led flowing

Who changed what in which revision?

UserRevisionLine numberNew contents of line
shiyilei 3:743f42c80067 1 /*********************************
shiyilei 3:743f42c80067 2 *file name:LED flow
shiyilei 3:743f42c80067 3 *creator: Jacob Shi
shiyilei 3:743f42c80067 4 *Time :2014/10/10
shiyilei 3:743f42c80067 5 *illustration : make the led1~
shiyilei 3:743f42c80067 6 *led3 flow
shiyilei 3:743f42c80067 7 ********************************/
mbed_official 0:b5a9e0614efd 8 #include "mbed.h"
shiyilei 3:743f42c80067 9 DigitalOut led1(LED1);
shiyilei 3:743f42c80067 10 DigitalOut led2(LED2);
shiyilei 3:743f42c80067 11 DigitalOut led3(LED3);
shiyilei 3:743f42c80067 12 int state=0;
shiyilei 3:743f42c80067 13 int main(void)
shiyilei 3:743f42c80067 14 {
shiyilei 3:743f42c80067 15 while(1)
shiyilei 3:743f42c80067 16 {
shiyilei 3:743f42c80067 17 switch(state)
shiyilei 3:743f42c80067 18 {
shiyilei 3:743f42c80067 19 case 0: led1=1;led2=0;led3=0;state++;break;
shiyilei 3:743f42c80067 20 case 1: led1=0;led2=1;led3=0;state++;break;
shiyilei 3:743f42c80067 21 case 2: led1=0;led2=0;led3=1;state++;break;
shiyilei 3:743f42c80067 22 default: break;
shiyilei 3:743f42c80067 23 }
shiyilei 3:743f42c80067 24 if(state==3)
shiyilei 3:743f42c80067 25 state=0;
shiyilei 3:743f42c80067 26 wait(0.3);
mbed_official 0:b5a9e0614efd 27 }
mbed_official 0:b5a9e0614efd 28 }
shiyilei 3:743f42c80067 29
shiyilei 3:743f42c80067 30