w1squarewave

Dependencies:   mbed

Committer:
occle
Date:
Thu Jan 12 15:41:24 2017 +0000
Revision:
0:e556da5831a8
w1squarewave

Who changed what in which revision?

UserRevisionLine numberNew contents of line
occle 0:e556da5831a8 1
occle 0:e556da5831a8 2 #include "mbed.h"
occle 0:e556da5831a8 3 DigitalOut redled(LED_RED);
occle 0:e556da5831a8 4 DigitalOut greenled(LED_GREEN);
occle 0:e556da5831a8 5 DigitalIn switchinput(SW2);
occle 0:e556da5831a8 6
occle 0:e556da5831a8 7 int main() {
occle 0:e556da5831a8 8 while(1) {
occle 0:e556da5831a8 9 if (switchinput==0) { //test value of switchinput
occle 0:e556da5831a8 10 //execute following block if switchinput is 1
occle 0:e556da5831a8 11 greenled = 1; //green led is off
occle 0:e556da5831a8 12 redled = 0; // flash red led
occle 0:e556da5831a8 13 wait(0.005);
occle 0:e556da5831a8 14 redled = 1;
occle 0:e556da5831a8 15 wait(0.005);
occle 0:e556da5831a8 16 } //end of if
occle 0:e556da5831a8 17 else { //here if switchinput is 1
occle 0:e556da5831a8 18 redled = 1; //red led is off
occle 0:e556da5831a8 19 greenled = 0; // flash green led
occle 0:e556da5831a8 20 wait(0.0025);
occle 0:e556da5831a8 21 greenled = 1;
occle 0:e556da5831a8 22 wait(0.0025);
occle 0:e556da5831a8 23 } //end of else
occle 0:e556da5831a8 24 } //end of while(1)
occle 0:e556da5831a8 25 } //end of main