Lab that has to do with basic IO on mbed.

Dependencies:   DebounceIn mbed PinDetect

JessesLab1/main.cpp

Committer:
Jesse Baker
Date:
2016-01-18
Revision:
42:841b1bf3f173
Parent:
41:5bcf3ab83113
Child:
43:a07c473ee4c7

File content as of revision 42:841b1bf3f173:

//* <- remove this if you want to code this and comment Georges
#include "mbed.h"
#include "DebounceIn.h"
#include "PinDetect.h"

PinDetect light(p8);
DebounceIn dimmer(p15);
PwmOut led(p21);

int main() {

float ind = 0;
float bright = 0;

  pb.mode(PullUp);

  while(1) {

    if(!dimmer) {
      ind = ind + 1;
      wait(1);
      if(ind <= 4) {
        ind = 0;
      }
    }

    bright = ind * 0.25;

    if(!light) {

      led.write(bright);

    }
    else {
      led.write(0);
    }
    //led = !pb;

  }
}