Lab that has to do with basic IO on mbed.
Dependencies: DebounceIn mbed PinDetect
Diff: JessesLab1/main.cpp
- Revision:
- 42:841b1bf3f173
- Parent:
- 41:5bcf3ab83113
- Child:
- 43:a07c473ee4c7
--- a/JessesLab1/main.cpp Mon Jan 18 03:40:13 2016 +0000 +++ b/JessesLab1/main.cpp Mon Jan 18 10:00:29 2016 -0500 @@ -3,16 +3,38 @@ #include "DebounceIn.h" #include "PinDetect.h" -PinDetect pb(p8); -DigitalOut led(p21); +PinDetect light(p8); +DebounceIn dimmer(p15); +PwmOut led(p21); int main() { +float ind = 0; +float bright = 0; + pb.mode(PullUp); while(1) { - led = !pb; + 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; } }