w1squarewave

Dependencies:   mbed

main.cpp

Committer:
occle
Date:
2017-01-12
Revision:
0:e556da5831a8

File content as of revision 0:e556da5831a8:


#include "mbed.h"
DigitalOut redled(LED_RED);
DigitalOut greenled(LED_GREEN);
DigitalIn switchinput(SW2);

int main() {
   while(1) {
      if (switchinput==0) { //test value of switchinput
//execute following block if switchinput is 1
          greenled = 1; //green led is off
          redled = 0; // flash red led
          wait(0.005);
          redled = 1;
          wait(0.005);
     } //end of if
    else { //here if switchinput is 1
      redled = 1; //red led is off
      greenled = 0; // flash green led
      wait(0.0025);
      greenled = 1;
      wait(0.0025);
    } //end of else
   } //end of while(1)
} //end of main