LED and button system

Dependencies:   mbed

Fork of LED by CHANG rozen

main.cpp

Committer:
e58136782000
Date:
2017-10-20
Revision:
1:59cafc988b1c
Parent:
0:6e75cf3220cb
Child:
2:7bb4b5066464

File content as of revision 1:59cafc988b1c:

#include "mbed.h"

DigitalOut led1(D4);
DigitalOut led2(D5);
DigitalOut led3(D6);
DigitalIn  button(D7);
void LED_Blinkly(DigitalOut led1,DigitalOut led2,DigitalOut led3);
// main() runs in its own thread in the OS
int main() 
{
    while(1)
    {

        if(button == true)
        {
           led1 =! led1;
           wait(0.5);
            led2 =! led2;
            wait(0.5);
            led3 =! led3;
           wait(0.5);    
        }
        else
        {
            led1 = false;
            led2 = false;
            led3 = false;
        }
    }
 //  int sw;
 //   printf("1");
 //  if(button == true)
 //  {
 //       sw = 1;
 //   }
 //   else
 //   {
 //       sw = 0;
 //   }
 //   if(sw == 1)
 //   {
 //       LED_Blinkly(led1,led2,led3);
 //   }
 //   else
 //   {
  //      while(false)
   //     {
  //          led1 = 0;
  //          led2 = 0;
   //         led3 = 0; 
  //          printf("off");
  //      }
 //   }
}
void LED_Blinkly(DigitalOut led1,DigitalOut led2,DigitalOut led3){
    while(true){
        led1 =! led1;
        wait(0.5);
        led2 =! led2;
        wait(0.5);
        led3 =! led3;
        wait(0.5);
        printf("on");
    }
}